home *** CD-ROM | disk | FTP | other *** search
/ Internet Info 1994 March / Internet Info CD-ROM (Walnut Creek) (March 1994).iso / inet / ien / ien-112 < prev    next >
Text File  |  1988-12-01  |  158KB  |  4,892 lines

  1.  
  2.                                                              August 1979
  3.  
  4. IEN:  112
  5.                                     
  6.                                     
  7.                                     
  8.                                     
  9.                                     
  10.                                     
  11.                                     
  12.                      TRANSMISSION CONTROL PROTOCOL
  13.                                     
  14.                                     
  15.                                     
  16.                               August 1979
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.                               prepared for
  36.                                     
  37.                Defense Advanced Research Projects Agency
  38.                 Information Processing Techniques Office
  39.                          1400 Wilson Boulevard
  40.                        Arlington, Virginia  22209
  41.                                     
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.                                    by
  49.  
  50.                      Information Sciences Institute
  51.                    University of Southern California
  52.                            4676 Admiralty Way
  53.                    Marina del Rey, California  90291
  54.  
  55. August 1979                                                             
  56.                                            Transmission Control Protocol
  57.  
  58.  
  59.  
  60.                            TABLE OF CONTENTS
  61.  
  62.     PREFACE ........................................................ iii
  63.  
  64. 1.  INTRODUCTION ..................................................... 1
  65.  
  66.   1.1  Motivation .................................................... 1
  67.   1.2  Scope ......................................................... 2
  68.   1.3  About This Document ........................................... 2
  69.   1.4  Interfaces .................................................... 3
  70.   1.5  Operation ..................................................... 3
  71.  
  72. 2.  PHILOSOPHY ....................................................... 7
  73.  
  74.   2.1  Elements of the Internetwork System ........................... 7
  75.   2.2  Model of Operation ............................................ 7
  76.   2.3  The Host Environment .......................................... 8
  77.   2.4  Interfaces .................................................... 9
  78.   2.5  Relation to Other Protocols ................................... 9
  79.   2.6  Reliable Communication ....................................... 10
  80.   2.7  Connection Establishment and Clearing ........................ 10
  81.   2.8  Data Communication ........................................... 12
  82.   2.9  Robustness Principle ......................................... 13
  83.  
  84. 3.  FUNCTIONAL SPECIFICATION ........................................ 15
  85.  
  86.   3.1  Header Format ................................................ 15
  87.   3.2  Terminology .................................................. 19
  88.   3.3  Sequence Numbers ............................................. 24
  89.   3.4  Establishing a connection .................................... 29
  90.   3.5  Closing a Connection ......................................... 35
  91.   3.6  Data Communication ........................................... 38
  92.   3.7  Interfaces ................................................... 41
  93.   3.8  Event Processing ............................................. 50
  94.  
  95. GLOSSARY ............................................................ 71
  96.  
  97. REFERENCES .......................................................... 79
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.                                                                 [Page i]
  112.  
  113.  
  114.                                                              August 1979
  115. Transmission Control Protocol
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.  
  141.  
  142.  
  143.  
  144.  
  145.  
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170. [Page ii]                                                               
  171.  
  172.  
  173. August 1979                                                             
  174.                                            Transmission Control Protocol
  175.  
  176.  
  177.  
  178.                                 PREFACE
  179.  
  180.  
  181.  
  182. This document describes the Transmission Control Protocol (TCP).  There
  183. have been six previous editions of the TCP specification, and the
  184. present text draws heavily from them.  There have been many contributors
  185. to this document both in terms of concepts and in terms of text.
  186.  
  187.                                                            Jon Postel
  188.  
  189.                                                            Editor
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205.  
  206.  
  207.  
  208.  
  209.  
  210.  
  211.  
  212.  
  213.  
  214.  
  215.  
  216.  
  217.  
  218.  
  219.  
  220.  
  221.  
  222.  
  223.  
  224.  
  225.  
  226.  
  227.  
  228.  
  229.                                                               [Page iii]
  230.  
  231.  
  232. August 1979 
  233. IEN:112
  234. Replaces:  IENs 81,
  235. 55, 44, 40, 27, 21, 5
  236.  
  237.  
  238.  
  239.  
  240.                      TRANSMISSION CONTROL PROTOCOL
  241.  
  242.  
  243.  
  244.                             1.  INTRODUCTION
  245.  
  246. The Transmission Control Protocol (TCP) is intended for use as a highly
  247. reliable host-to-host protocol between hosts in packet-switched computer
  248. communication networks, and especially in interconnected systems of such
  249. networks.
  250.  
  251. This document describes the functions to be performed by the
  252. Transmission Control Protocol, the program that implements it, and its
  253. interface to programs or users that require its services.
  254.  
  255. 1.1.  Motivation
  256.  
  257.   Computer communication systems are playing an increasingly important
  258.   role in military, government, and civilian environments.  This
  259.   document primarily focuses its attention on military computer
  260.   communication requirements, especially robustness in the presence of
  261.   communication unreliability, but many of these problems are found in
  262.   the civilian and government sector as well.
  263.  
  264.   As strategic and tactical computer communication networks are
  265.   developed and deployed, it is essential to provide means of
  266.   interconnecting them and to provide standard interprocess
  267.   communication protocols which can support a broad range of
  268.   applications.  In anticipation of the need for such standards, the
  269.   Deputy Undersecretary of Defense for Research and Engineering has
  270.   declared the Transmission Control Protocol (TCP) described herein to
  271.   be a basis for DoD-wide inter-process communication protocol
  272.   standardization.
  273.  
  274.   TCP is a connection-oriented, end-to-end reliable protocol designed to
  275.   fit into a layered hierarchy of protocols which support multi-network
  276.   applications.  The TCP provides for reliable inter-process
  277.   communication between pairs of processes in host computers attached to
  278.   distinct but interconnected computer communication networks.  Very few
  279.   assumptions are made as to the reliability of the communication
  280.   protocols below the TCP layer.  At most, the TCP assumes it can obtain
  281.   a simple, potentially unreliable datagram service from the lower level
  282.   protocols.  In principle, the TCP should be able to operate above a
  283.   wide spectrum of communication systems ranging from hard-wired
  284.   connections to packet-switched or circuit-switched networks.
  285.  
  286.  
  287.  
  288.                                                                 [Page 1]
  289.  
  290.  
  291.                                                              August 1979
  292. Transmission Control Protocol
  293. Introduction
  294.  
  295.  
  296.  
  297.   The TCP fits into a layered protocol architecture just above a basic
  298.   Internet Protocol [1] which provides a way for the TCP to send and
  299.   receive variable-length segments of information enclosed in internet
  300.   datagram "envelopes".  The internet datagram provides a means for
  301.   addressing source and destination TCPs in different networks, and that
  302.   layer of protocol also deals with any fragmentation or reassembly of
  303.   the TCP segments which might be required to achieve transport and
  304.   delivery through multiple networks and interconnecting gateways.
  305.  
  306.                            Protocol Layering
  307.  
  308.                         +---------------------+
  309.                         |     higher-level    |
  310.                         +---------------------+
  311.                         |        TCP          |
  312.                         +---------------------+
  313.                         |  internet protocol  |
  314.                         +---------------------+
  315.                         |communication network|
  316.                         +---------------------+
  317.  
  318.                                 Figure 1
  319.  
  320.   Much of this document is written in the context of TCP implementations
  321.   which are co-resident with higher level protocols in the host
  322.   computer.  As a practical matter, many computer systems will be
  323.   connected to networks via front-end computers which house the TCP and
  324.   internet protocol layers, as well as network specific software.  The
  325.   TCP specification describes an interface to the higher level protocols
  326.   which appears to be implementable even for the front-end case, as long
  327.   as a suitable host-to-front end protocol is implemented.
  328.  
  329. 1.2.  Scope
  330.  
  331.   The TCP is intended to provide a reliable process-to-process
  332.   communication service in a multinetwork environment.  The TCP is
  333.   intended to be a host-to-host protocol in common use in multiple
  334.   networks.
  335.  
  336. 1.3.  About this Document
  337.  
  338.   This document represents a specification of the behavior required of
  339.   any TCP implementation, both in its interactions with higher level
  340.   protocols and in its interactions with other TCPs.  The rest of this
  341.   section offers a very brief view of the protocol interfaces and
  342.   operation.  Section 2 summarizes the philosophical basis for the TCP
  343.   design.  Section 3 offers both a detailed description of the actions
  344.   required of TCP when various events occur (arrival of new segments,
  345.  
  346.  
  347. [Page 2]                                                                
  348.  
  349.  
  350. August 1979                                                             
  351.                                            Transmission Control Protocol
  352.                                                             Introduction
  353.  
  354.  
  355.  
  356.   user calls, errors, etc.) and the details of the formats of TCP
  357.   segments.
  358.  
  359. 1.4.  Interfaces
  360.  
  361.   The TCP interfaces on one side to user or application processes and on
  362.   the other side to a lower level protocol such as Internet Protocol.
  363.  
  364.   The interface between an application process and the TCP is
  365.   illustrated in reasonable detail.  This interface consists of a set of
  366.   calls much like the calls an operating system provides to application
  367.   process for manipulating files.  For example, there are calls to open
  368.   and close connections and to send and receive letters on established
  369.   connections.  It is also expected that the TCP can asynchronously
  370.   communicate with application programs.  Although considerable freedom
  371.   is permitted to TCP implementors to design interfaces which are
  372.   appropriate to a particular operating system environment, this TCP
  373.   specification requires a certain minimum functionality to be achieved
  374.   at the TCP/user interface for any valid implementation.
  375.  
  376.   The interface between TCP and lower level protocol is essentially
  377.   unspecified except that it is assume there is a mechanism whereby the
  378.   two can asynchronously pass information to each other.  Typically, one
  379.   expects the lower level protocol to specify this interface.  TCP is
  380.   designed to work in a very general environment of interconnected
  381.   networks.  Therefore, the lower level protocol which is assumed
  382.   throughout this document is the Internet Protocol.
  383.  
  384. 1.5.  Operation
  385.  
  386.   As noted above, the primary purpose of the TCP is to provide reliable
  387.   logical circuit or connection service between pairs of processes.  To
  388.   provide this service on top of a less reliable internet communication
  389.   system requires facilities in the following areas:
  390.  
  391.     Basic Data Transfer
  392.     Reliability
  393.     Flow Control
  394.     Multiplexing
  395.     Connections
  396.  
  397.   The basic operation of the TCP in each of these areas is described in
  398.   the following paragraphs.
  399.  
  400.  
  401.  
  402.  
  403.  
  404.  
  405.  
  406.                                                                 [Page 3]
  407.  
  408.  
  409.                                                              August 1979
  410. Transmission Control Protocol
  411. Introduction
  412.  
  413.  
  414.  
  415.   Basic Data Transfer:
  416.  
  417.     The TCP is able to transfer a continuous stream of octets in each
  418.     direction between its users by packaging some number of octets into
  419.     segments for transmission through the internet system.  In this
  420.     stream mode, the TCPs decide when to block and forward data at their
  421.     own convenience.
  422.  
  423.     For users who desire a record-oriented service, the TCP also permits
  424.     the user to submit records, called letters, for transmission.  When
  425.     the sending user indicates a record boundary (end-of-letter), this
  426.     causes the TCPs to promptly forward and deliver data up to that
  427.     point to the receiver.
  428.  
  429.   Reliability:
  430.  
  431.     The TCP must recover from data that is damaged, lost, duplicated, or
  432.     delivered out of order by the internet communication system.  This
  433.     is achieved by assigning a sequence number to each octet
  434.     transmitted, and requiring a positive acknowledgment (ACK) from the
  435.     receiving TCP.  If the ACK is not received within a timeout
  436.     interval, the data is retransmitted.  At the receiver, the sequence
  437.     numbers are used to correctly order segments that may be received
  438.     out of order and to eliminate duplicates.  Damage is handled by
  439.     adding a checksum to each segment transmitted, checking it at the
  440.     receiver, and discarding damaged segments.
  441.  
  442.     As long as the TCPs continue to function properly and the internet
  443.     system does not become completely partitioned, no transmission
  444.     errors will affect the users.  All errors in the internet
  445.     communication system are recovered by the TCP.
  446.  
  447.   Flow Control:
  448.  
  449.     TCP provides a means for the receiver to govern the amount of data
  450.     sent by the sender.  This is achieved by returning a "window" with
  451.     every ACK indicating a range of acceptable sequence numbers beyond
  452.     the last segment successfully received.  For stream mode, the window
  453.     indicates an allowed number of octets that the sender may transmit
  454.     before receiving further permission.  It is also possible for the
  455.     TCP to operate in a mode where buffer sizes and letter boundaries
  456.     are incorporated in flow control.
  457.  
  458.   Multiplexing:
  459.  
  460.     To allow for many processes within a single Host to use TCP
  461.     communication facilities simultaneously, the TCP provides a set of
  462.     addresses or ports within each host.  Concatenated with the network
  463.  
  464.  
  465. [Page 4]                                                                
  466.  
  467.  
  468. August 1979                                                             
  469.                                            Transmission Control Protocol
  470.                                                             Introduction
  471.  
  472.  
  473.  
  474.     and host addresses from the internet communication layer, this forms
  475.     a socket.  A pair of sockets uniquely identifies each connection.
  476.     That is, different connections may have a common socket on one side,
  477.     but the sockets on the other sides must be different.
  478.  
  479.     The binding of ports to processes is handled independently by each
  480.     Host.  However, it proves useful to attach frequently used processes
  481.     (e.g., a "logger" or timesharing service) to fixed sockets which are
  482.     made known to the public.  These services can then be accessed
  483.     through the known addresses.  Establishing and learning the port
  484.     addresses of other processes may involve more dynamic mechanisms.
  485.  
  486.   Connections:
  487.  
  488.     The reliability and flow control mechanisms described above require
  489.     that TCPs initialize and maintain certain status information for
  490.     each data stream.  The combination of this information, including
  491.     sockets, sequence numbers, and window sizes, is called a connection.
  492.     Each connection is uniquely specified by a pair of sockets
  493.     identifying its two sides.
  494.  
  495.     When two processes wish to communicate, their TCP's must first
  496.     establish a connection (initialize the status information on each
  497.     side).  When their communication is complete, the connection is
  498.     terminated or closed to free the resources for other uses.
  499.  
  500.     Since connections must be established over the unreliable internet
  501.     communication system, a handshake mechanism with clock-based
  502.     sequence numbers is used to avoid erroneous initialization of
  503.     connections.
  504.  
  505.     
  506.  
  507.  
  508.  
  509.  
  510.  
  511.  
  512.  
  513.  
  514.  
  515.  
  516.  
  517.  
  518.  
  519.  
  520.  
  521.  
  522.  
  523.  
  524.                                                                 [Page 5]
  525.  
  526.  
  527.                                                              August 1979
  528. Transmission Control Protocol
  529.  
  530.  
  531.  
  532.  
  533.  
  534.  
  535.  
  536.  
  537.  
  538.  
  539.  
  540.  
  541.  
  542.  
  543.  
  544.  
  545.  
  546.  
  547.  
  548.  
  549.  
  550.  
  551.  
  552.  
  553.  
  554.  
  555.  
  556.  
  557.  
  558.  
  559.  
  560.  
  561.  
  562.  
  563.  
  564.  
  565.  
  566.  
  567.  
  568.  
  569.  
  570.  
  571.  
  572.  
  573.  
  574.  
  575.  
  576.  
  577.  
  578.  
  579.  
  580.  
  581.  
  582.  
  583. [Page 6]                                                                
  584.  
  585.  
  586. August 1979                                                             
  587.                                            Transmission Control Protocol
  588.  
  589.  
  590.  
  591.                              2.  PHILOSOPHY
  592.  
  593. 2.1.  Elements of the Internetwork System
  594.  
  595.   The internetwork environment consists of hosts connected to networks
  596.   which are in turn interconnected via gateways.  It is assumed here
  597.   that the networks may be either local networks (e.g., the ETHERNET) or
  598.   large networks (e.g., the ARPANET), but in any case are based on
  599.   packet switching technology.  The active agents that produce and
  600.   consume messages are processes.  Various levels of protocols in the
  601.   networks, the gateways, and the hosts support an interprocess
  602.   communication system that provides two-way data flow on logical
  603.   connections between process ports.
  604.  
  605.   We specifically assume that data is transmitted from host to host
  606.   through means of a set of  networks.  When we say network, we have in
  607.   mind a packet switched network (PSN).  This assumption is probably
  608.   unnecessary, since a circuit switched network or a hybrid combination
  609.   of the two could also be used; but for concreteness, we explicitly
  610.   assume that the hosts are connected to one or more packet switches of
  611.   a PSN.
  612.  
  613.   The term packet is used generically here to mean the data of one
  614.   transaction between a host and a packet switch.  The format of data
  615.   blocks exchanged between the packet switches in a network will
  616.   generally not be of concern to us.
  617.  
  618.   Hosts are computers attached to a network, and from the communication
  619.   network's point of view, are the sources and destinations of packets.
  620.   Processes are viewed as the active elements in host computers (in
  621.   accordance with the fairly common definition of a process as a program
  622.   in execution).  Even terminals and files or other I/O devices are
  623.   viewed as communicating with each other through the use of processes.
  624.   Thus, all communication is viewed as inter-process communication.
  625.  
  626.   Since a process may need to distinguish among several communication
  627.   streams between itself and another process (or processes), we imagine
  628.   that each process may have a number of ports through which it
  629.   communicates with the ports of other processes.
  630.  
  631. 2.2.  Model of Operation
  632.  
  633.   Processes transmit data by calling on the TCP and passing buffers of
  634.   data as arguments.  The TCP packages the data from these buffers into
  635.   segments and calls on the internet module to transmit each segment to
  636.   the destination TCP.  The receiving TCP places the data from a segment
  637.   into the receiving users buffer and notifies the receiving user.  The
  638.   TCPs include control information in the segments which they use to
  639.   ensure reliable ordered data transmission.
  640.  
  641.  
  642.                                                                 [Page 7]
  643.  
  644.  
  645.                                                              August 1979
  646. Transmission Control Protocol
  647. Philosophy
  648.  
  649.  
  650.  
  651.   The model of internet communication is that there is a basic gateway
  652.   (or internet protocol module) associated with each TCP which provides
  653.   an interface to the local network.  This basic gateway packages TCP
  654.   segments inside internet datagrams and routes these datagrams to a
  655.   destination or intermediate gateway.  To transmit the datagram through
  656.   the local network, it is embedded in a local network packet.
  657.  
  658.   The packet switches may perform further packaging, fragmentation, or
  659.   other operations to achieve the delivery of the local packet to the
  660.   destination gateway.
  661.  
  662.   At a gateway between networks, the internet datagram is "unwrapped"
  663.   from its local packet and examined to determine through which network
  664.   the internet datagram should travel next.  The internet datagram is
  665.   then "wrapped" in a local packet suitable to the next network and
  666.   routed to the next gateway.
  667.  
  668.   A gateway is permitted to break up an internet datagram into smaller
  669.   internet datagram fragments if this is necessary for transmission
  670.   through the next network.  To do this, the gateway produces a set of
  671.   internet datagrams; each carrying a fragment.  Fragments may be broken
  672.   into smaller ones at intermediate gateways.  The internet datagram
  673.   fragment format is designed so that the destination gateway can
  674.   reassemble fragments into internet datagrams.
  675.  
  676.   A destination gateway unwraps the segment from the datagram (after
  677.   reassembling the datagram, if necessary) and passes it to the
  678.   destination TCP.
  679.  
  680. 2.3.  The Host Environment
  681.  
  682.   The TCP is assumed to be a module in a time sharing operating system.
  683.   The users access the TCP much like they would access the file system.
  684.   The TCP may call on other operating system functions, for example, to
  685.   manage data structures.  The actual interface to the network is
  686.   assumed to be controlled by a device driver module.  The TCP does not
  687.   call on the network device driver directly, but rather calls on the
  688.   internet datagram protocol module which may in turn call on the device
  689.   driver.
  690.  
  691.   Though it is assumed here that processes are supported by the host
  692.   operating system, the mechanisms of TCP do not preclude implementation
  693.   of the TCP in a front-end processor.  However, in such an
  694.   implementation, a host-to-front-end protocol must provide the
  695.   functionality to support the type of TCP-user interface described
  696.   above.
  697.  
  698.  
  699.  
  700.  
  701. [Page 8]                                                                
  702.  
  703.  
  704. August 1979                                                             
  705.                                            Transmission Control Protocol
  706.                                                               Philosophy
  707.  
  708.  
  709.  
  710. 2.4.  Interfaces
  711.  
  712.   The TCP/user interface provides for calls made by the user on the TCP
  713.   to OPEN or CLOSE a connection, to SEND or RECEIVE data, or to obtain
  714.   STATUS about a connection.  These calls are like other calls from user
  715.   programs on the operating system, for example, the calls to open, read
  716.   from, and close a file.
  717.  
  718.   The TCP/internet interface provides calls to send and receive
  719.   datagrams addressed to TCP modules in hosts anywhere in the internet
  720.   system.
  721.  
  722. 2.5.  Relation to Other Protocols
  723.  
  724.   The following diagram illustrates the place of the TCP in the protocol
  725.   hierarchy:
  726.  
  727.                                     
  728.        +------+ +-----+ +-----+       +-----+                    
  729.        |Telnet| | FTP | |Voice|  ...  |     |  Application Level 
  730.        +------+ +-----+ +-----+       +-----+                    
  731.              |   |         |             |                       
  732.             +-----+     +-----+       +-----+                    
  733.             | TCP |     | RTP |  ...  |     |  Host Level        
  734.             +-----+     +-----+       +-----+                    
  735.                |           |             |                       
  736.             +-------------------------------+                    
  737.             |      Internet Protocol        |  Gateway Level     
  738.             +-------------------------------+                    
  739.                            |                                     
  740.               +---------------------------+                      
  741.               |   Local Network Protocol  |    Network Level     
  742.               +---------------------------+                      
  743.                            |                                     
  744.  
  745.  
  746.  
  747.                          Protocol Relationships
  748.  
  749.                                Figure 2.
  750.  
  751.   It is expected that the TCP will be able to support higher level
  752.   protocols efficiently.  It should be easy to interface higher level
  753.   protocols like the ARPANET TELNET and FTP [2] to the TCP.
  754.  
  755.  
  756.  
  757.  
  758.  
  759.  
  760.                                                                 [Page 9]
  761.  
  762.  
  763.                                                              August 1979
  764. Transmission Control Protocol
  765. Philosophy
  766.  
  767.  
  768.  
  769. 2.6.  Reliable Communication
  770.  
  771.   A stream of data sent on a TCP connection is delivered reliably and in
  772.   order at the destination.
  773.  
  774.   Transmission is made reliable via the use of sequence numbers and
  775.   acknowledgments.  Conceptually, each octet of data is assigned a
  776.   sequence number.  The sequence number of the first octet of data in a
  777.   segment is the sequence number transmitted with that segment and is
  778.   called the segment sequence number.  Segments also carry an
  779.   acknowledgment number which is the sequence number of the most recent
  780.   data octet of transmissions in the reverse direction which has been
  781.   accepted.  When the TCP transmits a segment, it puts a copy on a
  782.   retransmission queue and starts a timer; when the acknowledgment for
  783.   that data is received, the segment is deleted from the queue.  If the
  784.   acknowledgment is not received before the timer runs out, the segment
  785.   is retransmitted.
  786.  
  787.   An acknowledgment by TCP does not guarantee that the data has been
  788.   delivered to the end user, but only that the TCP has taken the
  789.   responsibility to do so.
  790.  
  791.   To govern the flow of data into a TCP, a flow control mechanism is
  792.   employed.  The the data receiving TCP reports a window to the sending
  793.   TCP.  This window is a number of octets beyond the currently
  794.   acknowledged sequence number that the data receiving TCP is currently
  795.   prepared to receive.
  796.  
  797. 2.7.  Connection Establishment and Clearing
  798.  
  799.   To identify the separate data streams that a TCP may handle, the TCP
  800.   provides a port identifier.  Since port identifiers are selected
  801.   independently by each operating system, TCP, or user, they might not
  802.   be unique.  To provide for unique addresses at each TCP, we
  803.   concatenate an internet address identifying the TCP with a port
  804.   identifier to create a socket which will be unique throughout all
  805.   networks connected together.
  806.  
  807.   A connection is fully specified by the pair of sockets at the ends,
  808.   since the same local socket may participate in many connections to
  809.   different foreign sockets.  A connection can be used to carry data in
  810.   both directions, that is, it is "full duplex".
  811.  
  812.   TCPs are free to associate ports with processes however they choose.
  813.   However, several basic concepts seem necessary in any implementation.
  814.   There must be well-known sockets which the TCP associates only with
  815.   the "appropriate" processes by some means.  We envision that processes
  816.   may "own" ports, and that processes can only initiate connections on
  817.  
  818.  
  819. [Page 10]                                                               
  820.  
  821.  
  822. August 1979                                                             
  823.                                            Transmission Control Protocol
  824.                                                               Philosophy
  825.  
  826.  
  827.  
  828.   the ports they own.  (Means for implementing ownership is a local
  829.   issue, but we envision a Request Port user command, or a method of
  830.   uniquely allocating a group of ports to a given process, e.g., by
  831.   associating the high order bits of a port name with a given process.)
  832.  
  833.   A connection is specified in the OPEN call by the local port and
  834.   foreign socket arguments.  In return, the TCP supplies a (short) local
  835.   connection name by which the user refers to the connection in
  836.   subsequent calls.  There are several things that must be remembered
  837.   about a connection.  To store this information we imagine that there
  838.   is a data structure called a Transmission Control Block (TCB).  One
  839.   implementation strategy would have the local connection name be a
  840.   pointer to the TCB for this connection.  The OPEN call also specifies
  841.   whether the connection establishment is to be actively pursued, or to
  842.   be passively waited for.
  843.  
  844.   A foreign socket of all zeros is called unspecified.  The purpose
  845.   behind unspecified sockets is to provide a sort of "general delivery"
  846.   facility (useful for processes offering services).  This is allowed
  847.   only for passive OPENs.
  848.  
  849.   A service process that wished to provide services for unknown other
  850.   processes could issue a passive OPEN request with an unspecified
  851.   foreign socket.  Then a connection could be made with any process that
  852.   requested a connection to this local socket.  It would help if this
  853.   local socket were known to be associated with this service.
  854.  
  855.   Well-known sockets are a convenient mechanism for a priori associating
  856.   a socket address with a standard service.  For instance, the
  857.   "Telnet-Server" process might be permanently assigned to a particular
  858.   socket, and other sockets might be reserved for File Transfer, Remote
  859.   Job Entry, Text Generator, Echoer, and Sink processes (the last three
  860.   being for test purposes).  A socket address might be reserved for
  861.   access to a "Look-Up" service which would return the specific socket
  862.   at which a newly created service would be provided.  The concept of a
  863.   well-known socket is part of the TCP specification, but the assignment
  864.   of sockets to services is outside this specification.
  865.  
  866.   Processes can issue passive OPENs and wait for matching calls from
  867.   other processes and be informed by the TCP when connections have been
  868.   established.  Two processes which issue calls to each other at the
  869.   same time are correctly connected.  This flexibility is critical for
  870.   the support of distributed computing in which components act
  871.   asynchronously with each other.
  872.  
  873.   There are two cases for matching the sockets in the local request and
  874.   an incoming segment.  In the first case, the local request has fully
  875.   specified the foreign socket.  In this case, the match must be exact.
  876.  
  877.  
  878.                                                                [Page 11]
  879.  
  880.  
  881.                                                              August 1979
  882. Transmission Control Protocol
  883. Philosophy
  884.  
  885.  
  886.  
  887.   In the second case, the local request has left the foreign socket
  888.   unspecified.  In this case, any foreign socket is acceptable as long
  889.   as the local sockets match.
  890.  
  891.   If there are several pending passive OPENs (recorded in TCBs) with the
  892.   same local socket, an incoming segment should be matched to a request
  893.   with the specific foreign socket in the segment, if such a request
  894.   exists, before selecting a request with an unspecified foreign socket.
  895.  
  896.   The procedures to establish and clear connections utilize synchronize
  897.   (SYN) and finis (FIN) control flags and involve an exchange of three
  898.   messages.  This exchange has been termed a three-way hand shake [3].
  899.  
  900.   A connection is initiated by the rendezvous of an arriving segment
  901.   containing a SYN and a waiting TCB entry created by a user OPEN
  902.   command.  The matching of local and foreign sockets determines when a
  903.   connection has been initiated.  The connection becomes "established"
  904.   when sequence numbers have been synchronized in both directions.
  905.  
  906.   The clearing of a connection also involves the exchange of segments,
  907.   in this case carrying the FIN control flag.
  908.  
  909. 2.8.  Data Communication
  910.  
  911.   The data that flows on a connection may be thought of as a stream of
  912.   octets, or as a sequence of records.  In TCP the records are called
  913.   letters and are of variable length.  The sending user indicates in
  914.   each SEND call if the data in that call completes a letter by the
  915.   setting of the end-of-letter parameter.
  916.  
  917.   The length of a letter may be such that it must be broken into
  918.   segments before it can be transmitted to its destination.  We assume
  919.   that the segments will normally be reassembled into a letter before
  920.   being passed to the receiving process.  A segment may contain all or a
  921.   part of a letter, but a segment never contains parts of more than one
  922.   letter.  The end of a letter is marked by the appearance of an EOL
  923.   control flag in a segment.  A sending TCP is allowed to collect data
  924.   from the sending user and to send that data in segments at its own
  925.   convenience, until the end of letter is signaled then it must send all
  926.   unsent data.  When a receiving TCP has a complete letter, it must not
  927.   wait for more data from the sending TCP before passing the letter to
  928.   the receiving process.
  929.  
  930.   There is a coupling between letters as sent and the use of buffers of
  931.   data that cross the TCP/user interface.  Each time an end-of-letter
  932.   (EOL) flag is associated with data placed into the receiving user's
  933.   buffer, the buffer is returned to the user for processing even if the
  934.  
  935.  
  936.  
  937. [Page 12]                                                               
  938.  
  939.  
  940. August 1979                                                             
  941.                                            Transmission Control Protocol
  942.                                                               Philosophy
  943.  
  944.  
  945.  
  946.   buffer is not filled.  If a letter is longer than the user's buffer,
  947.   the letter is passed to the user in buffer size units.
  948.  
  949.   The TCP is responsible for regulating the flow of segments to and from
  950.   the on the connections, as a way of preventing itself from becoming
  951.   saturated or overloaded with traffic.  This is done using a window
  952.   flow control mechanism.  The data receiving TCP reports to the data
  953.   sending TCP a window which is the range of sequence numbers of data
  954.   octets that data receiving TCP is currently prepared to accept.
  955.  
  956.   TCP also provides a means to communicate to the receiver of data that
  957.   at some point further along in the data stream than the receiver is
  958.   currently reading there is urgent data.  TCP does not attempt to
  959.   define what the user specifically does upon being notified of pending
  960.   urgent data, but the general notion is that the receiving process
  961.   should take action to read through the end urgent data quickly.
  962.  
  963. 2.9.  Robustness Principle
  964.  
  965.   TCP implementations should follow a general principle of robustness:
  966.   be conservative in what you do, be liberal in what you accept from
  967.   others.
  968.  
  969.   
  970.  
  971.  
  972.  
  973.  
  974.  
  975.  
  976.  
  977.  
  978.  
  979.  
  980.  
  981.  
  982.  
  983.  
  984.  
  985.  
  986.  
  987.  
  988.  
  989.  
  990.  
  991.  
  992.  
  993.  
  994.  
  995.  
  996.                                                                [Page 13]
  997.  
  998.  
  999.                                                              August 1979
  1000. Transmission Control Protocol
  1001.  
  1002.  
  1003.  
  1004.  
  1005.  
  1006.  
  1007.  
  1008.  
  1009.  
  1010.  
  1011.  
  1012.  
  1013.  
  1014.  
  1015.  
  1016.  
  1017.  
  1018.  
  1019.  
  1020.  
  1021.  
  1022.  
  1023.  
  1024.  
  1025.  
  1026.  
  1027.  
  1028.  
  1029.  
  1030.  
  1031.  
  1032.  
  1033.  
  1034.  
  1035.  
  1036.  
  1037.  
  1038.  
  1039.  
  1040.  
  1041.  
  1042.  
  1043.  
  1044.  
  1045.  
  1046.  
  1047.  
  1048.  
  1049.  
  1050.  
  1051.  
  1052.  
  1053.  
  1054.  
  1055. [Page 14]                                                               
  1056.  
  1057.  
  1058. August 1979                                                             
  1059.                                            Transmission Control Protocol
  1060.  
  1061.  
  1062.  
  1063.                       3.  FUNCTIONAL SPECIFICATION
  1064.  
  1065. 3.1.  Header Format
  1066.  
  1067.   TCP segments are sent as internet datagrams.  The Internet Protocol
  1068.   header carries several information fields, including the source and
  1069.   destination host addresses [1].  A TCP header follows the internet
  1070.   header, supplying information specific to the TCP protocol.  This
  1071.   division allows for the existence of host level protocols other than
  1072.   TCP.
  1073.  
  1074.   TCP Header Format
  1075.  
  1076.                                     
  1077.     0                   1                   2                   3   
  1078.     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 
  1079.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1080.    |          Source Port          |       Destination Port        |
  1081.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1082.    |                        Sequence Number                        |
  1083.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1084.    |                    Acknowledgment Number                      |
  1085.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1086.    |  Data |           |U|A|E|R|S|F|                               |
  1087.    | Offset| Reserved  |R|C|O|S|Y|I|            Window             |
  1088.    |       |           |G|K|L|T|N|N|                               |
  1089.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1090.    |           Checksum            |         Urgent Pointer        |
  1091.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1092.    |                    Options                    |    Padding    |
  1093.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1094.    |                             data                              |
  1095.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1096.  
  1097.                             TCP Header Format
  1098.  
  1099.           Note that one tick mark represents one bit position.
  1100.  
  1101.                                Figure 3.
  1102.  
  1103.   Source Port:  16 bits
  1104.  
  1105.     The source port number.
  1106.  
  1107.   Destination Port:  16 bits
  1108.  
  1109.     The destination port number.
  1110.  
  1111.  
  1112.  
  1113.  
  1114.                                                                [Page 15]
  1115.  
  1116.  
  1117.                                                              August 1979
  1118. Transmission Control Protocol
  1119. Functional Specification
  1120.  
  1121.  
  1122.  
  1123.   Sequence Number:  32 bits
  1124.  
  1125.     The sequence number of the first data octet in this segment.
  1126.  
  1127.   Acknowledgment Number:  32 bits
  1128.  
  1129.     If the ACK control bit is set this field contains the value of the
  1130.     next sequence number the sender of the segment is expecting to
  1131.     receive.
  1132.  
  1133.   Data Offset:  4 bits
  1134.  
  1135.     The number of 32 bit words in the TCP Header.  This indicates where
  1136.     the data begins.  The TCP header including options is an integral
  1137.     number of 32 bits long.
  1138.  
  1139.   Reserved:  6 bits
  1140.  
  1141.     Reserved for future use.  Must be zero.
  1142.  
  1143.   Control Bits:  8 bits (from left to right):
  1144.  
  1145.     URG:  Urgent Pointer field significant
  1146.     ACK:  Acknowledgment field significant
  1147.     EOL:  End of Letter
  1148.     RST:  Reset the connection
  1149.     SYN:  Synchronize sequence numbers
  1150.     FIN:  No more data from sender
  1151.  
  1152.   Window:  16 bits
  1153.  
  1154.     The number of data octets beyond the one indicated in the
  1155.     acknowledgment field which the sender of this segment is willing to
  1156.     accept.
  1157.  
  1158.   Checksum:  16 bits
  1159.  
  1160.     The checksum field is the 16 bit one's complement of the one's
  1161.     complement sum of all 16 bit words in the header and text.  If a
  1162.     segment contains an odd number of header and text octets to be
  1163.     checksummed, the last octet is padded with zeros to form a 16 bit
  1164.     word for checksum purposes.  The pad is not transmitted as part of
  1165.     the segment.  While computing the checksum, the checksum field
  1166.     itself is replaced with zeros.
  1167.  
  1168.     The checksum also covers a 96 bit pseudo header conceptually
  1169.     prefixed to the TCP header.  This pseudo header contains the Source
  1170.     Address, the Destination Address, the Protocol, and TCP length.
  1171.  
  1172.  
  1173. [Page 16]                                                               
  1174.  
  1175.  
  1176. August 1979                                                             
  1177.                                            Transmission Control Protocol
  1178.                                                 Functional Specification
  1179.  
  1180.  
  1181.  
  1182.     This gives the TCP protection against misrouted segments.  This
  1183.     information is carried in the Internet Protocol and is transfered
  1184.     across the TCP/Network interface in the arguments or results of
  1185.     calls by the TCP on the IP.
  1186.  
  1187.                      +--------------------------+
  1188.                      |      Source Address      |
  1189.                      +--------------------------+
  1190.                      |    Destination Address   |
  1191.                      +--------------------------+
  1192.                      | zero | PTCL | TCP Length |
  1193.                      +--------------------------+
  1194.  
  1195.       The TCP Length is the TCP header plus the data length in octets
  1196.       (this is not a explicitly transmitted quantity, but is computed
  1197.       from the total length, and the header length).
  1198.  
  1199.   Urgent Pointer:  16 bits
  1200.  
  1201.     This field communicates the current value of the urgent pointer as a
  1202.     positive offset from the sequence number in this segment.  The
  1203.     urgent pointer points to the sequence number of the octet following
  1204.     the urgent data.  This field should only be interpreted in segments
  1205.     with the URG control bit set.
  1206.  
  1207.   Options:  variable
  1208.  
  1209.     Options may occupy space at the end of the TCP header and are a
  1210.     multiple of 8 bits in length.  All options are included in the
  1211.     checksum.  An option may begin on any octet boundary.  There are two
  1212.     cases for the format of an option:
  1213.  
  1214.       Case 1:  A single octet of option-kind.
  1215.  
  1216.       Case 2:  An octet of option-kind, an octet of option-length, and
  1217.                the actual option-data octets.
  1218.  
  1219.     The option-length counts the two octets of option-kind and
  1220.     option-length as well as the option-data octets.
  1221.  
  1222.     Note that the list of options may be shorter than the data offset
  1223.     field might imply.  The content of the header beyond the
  1224.     End-of-Option option should be header padding (i.e., zero).
  1225.  
  1226.     A TCP must implement all options.
  1227.  
  1228.  
  1229.  
  1230.  
  1231.  
  1232.                                                                [Page 17]
  1233.  
  1234.  
  1235.                                                              August 1979
  1236. Transmission Control Protocol
  1237. Functional Specification
  1238.  
  1239.  
  1240.  
  1241.     Currently defined options include (kind indicated in octal):
  1242.  
  1243.       Kind     Length    Meaning
  1244.       ----     ------    -------
  1245.        0         -       End of option list.
  1246.        1         -       No-Operation.
  1247.       100        -       Reserved.
  1248.       105        4       Buffer Size.
  1249.       
  1250.  
  1251.     Specific Option Definitions
  1252.  
  1253.       End of Option List
  1254.  
  1255.         +--------+
  1256.         |00000000|
  1257.         +--------+
  1258.          Kind=0
  1259.  
  1260.         This option code indicates the end of the option list.  This
  1261.         might not coincide with the end of the TCP header according to
  1262.         the Data Offset field.  This is used at the end of all options,
  1263.         not the end of each option, and need only be used if the end of
  1264.         the options would not otherwise coincide with the end of the TCP
  1265.         header.
  1266.  
  1267.       No-Operation
  1268.  
  1269.         +--------+
  1270.         |00000001|
  1271.         +--------+
  1272.          Kind=1
  1273.  
  1274.         This option code may be used between options, for example, to
  1275.         align the beginning of a subsequent option on a word boundary.
  1276.         There is no guarantee that senders will use this option, so
  1277.         receivers must be prepared to process options even if they do
  1278.         not begin on a word boundary.
  1279.  
  1280.       Buffer Size
  1281.  
  1282.         +--------+--------+---------+--------+
  1283.         |01000101|00000100|    buffer size   |
  1284.         +--------+--------+---------+--------+
  1285.          Kind=105 Length=4
  1286.  
  1287.  
  1288.  
  1289.  
  1290.  
  1291. [Page 18]                                                               
  1292.  
  1293.  
  1294. August 1979                                                             
  1295.                                            Transmission Control Protocol
  1296.                                                 Functional Specification
  1297.  
  1298.  
  1299.  
  1300.         Buffer Size Option Data:  16 bits
  1301.  
  1302.           If this option is present, then it communicates the receive
  1303.           buffer size at the TCP which sends this segment.  This field
  1304.           should only be sent in segments with the SYN control bit set.
  1305.           If this option is not used, the default buffer size of one
  1306.           octet is assumed.
  1307.  
  1308.   Padding:  variable
  1309.  
  1310.     The TCP header padding is used to ensure that the TCP header ends
  1311.     and data begins on a 32 bit boundary.  The padding is composed of
  1312.     zeros.
  1313.  
  1314. 3.2.  Terminology
  1315.  
  1316.   Before we can discuss very much about the operation of the TCP we need
  1317.   to introduce some detailed terminology.  The maintenance of a TCP
  1318.   connection requires the remembering of several variables.  We conceive
  1319.   of these variables being stored in a connection record called a
  1320.   Transmission Control Block or TCB.  Among the variables stored in the
  1321.   TCB are the local and remote socket numbers, pointers to the user's
  1322.   send and receive buffers, pointers to the retransmit queue and to the
  1323.   current segment.  In addition several variables relating to the send
  1324.   and receive sequence numbers are stored in the TCB.
  1325.  
  1326.     Send Sequence Variables
  1327.  
  1328.       SND.UNA - send unacknowledged
  1329.       SND.NXT - send sequence
  1330.       SND.WND - send window
  1331.       SND.BS  - send buffer size
  1332.       SND.UP  - send urgent pointer
  1333.       SND.WL  - send sequence number used for last window update
  1334.       SND.LBB - send last buffer beginning
  1335.       ISS     - initial send sequence number
  1336.  
  1337.     Receive Sequence Variables
  1338.  
  1339.       RCV.NXT - receive sequence
  1340.       RCV.WND - receive window
  1341.       RCV.BS  - receive buffer size
  1342.       RCV.UP  - receive urgent pointer
  1343.       RCV.LBB - receive last buffer beginning
  1344.       IRS     - initial receive sequence number
  1345.  
  1346.  
  1347.  
  1348.  
  1349.  
  1350.                                                                [Page 19]
  1351.  
  1352.  
  1353.                                                              August 1979
  1354. Transmission Control Protocol
  1355. Functional Specification
  1356.  
  1357.  
  1358.  
  1359.   The following diagrams may help to relate some of these variables to
  1360.   the sequence space.
  1361.  
  1362.   Send Sequence Space
  1363.  
  1364.                    1         2          3          4      
  1365.               ----------|----------|----------|---------- 
  1366.                      SND.UNA    SND.NXT    SND.UNA        
  1367.                                           +SND.WND        
  1368.  
  1369.         1 - old sequence numbers which have been acknowledged  
  1370.         2 - sequence numbers of unacknowledged data            
  1371.         3 - sequence numbers allowed for new data transmission 
  1372.         4 - future sequence numbers which are not yet allowed  
  1373.  
  1374.                           Send Sequence Space
  1375.  
  1376.                                Figure 4.
  1377.     
  1378.     
  1379.  
  1380.   Receive Sequence Space
  1381.  
  1382.                        1          2          3      
  1383.                    ----------|----------|---------- 
  1384.                           RCV.NXT    RCV.NXT        
  1385.                                     +RCV.WND        
  1386.  
  1387.         1 - old sequence numbers which have been acknowledged  
  1388.         2 - sequence numbers allowed for new reception         
  1389.         3 - future sequence numbers which are not yet allowed  
  1390.  
  1391.                          Receive Sequence Space
  1392.  
  1393.                                Figure 5.
  1394.     
  1395.     
  1396.  
  1397.   There are also some variables used frequently in the discussion that
  1398.   take their values from the fields of the current segment.
  1399.  
  1400.     Current Segment Variables
  1401.  
  1402.       SEG.SEQ - segment sequence number
  1403.       SEG.ACK - segment acknowledgment number
  1404.       SEG.LEN - segment length
  1405.       SEG.WND - segment window
  1406.       SEG.UP  - segment urgent pointer
  1407.  
  1408.  
  1409. [Page 20]                                                               
  1410.  
  1411.  
  1412. August 1979                                                             
  1413.                                            Transmission Control Protocol
  1414.                                                 Functional Specification
  1415.  
  1416.  
  1417.  
  1418.   A connection progresses through a series of states during its
  1419.   lifetime.  The states are:  LISTEN, SYN-SENT, SYN-RECEIVED,
  1420.   ESTABLISHED, FIN-WAIT-1, FIN-WAIT-2, TIME-WAIT, CLOSE-WAIT, CLOSING,
  1421.   and the fictional state CLOSED.  Closed is fictional because it
  1422.   represents the state when there is no TCB, and therefore, no
  1423.   connection.  Briefly the meanings of the states are:
  1424.  
  1425.     LISTEN - represents waiting for a connection request from any remote
  1426.     TCP and port.
  1427.  
  1428.     SYN-SENT - represents waiting for a matching connection request
  1429.     after having sent a connection request.
  1430.  
  1431.     SYN-RECEIVED - represents waiting for a confirming connection
  1432.     request acknowledgment after having both sent and received a
  1433.     connection request.
  1434.  
  1435.     ESTABLISHED - represents an open connection, ready to transmit and
  1436.     receive data segments.
  1437.  
  1438.     FIN-WAIT-1 - represents waiting for a connection termination request
  1439.     from the remote TCP, or an acknowledgment of the connection
  1440.     termination request previously sent.
  1441.  
  1442.     FIN-WAIT-2 - represents waiting for a connection termination request
  1443.     from the remote TCP.
  1444.  
  1445.     TIME-WAIT - represents waiting for enough time to pass to be sure
  1446.     the remote TCP received the acknowledgment of its connection
  1447.     termination request.
  1448.  
  1449.     CLOSE-WAIT - represents waiting for a connection termination request
  1450.     from the local user.
  1451.  
  1452.     CLOSING - represents waiting for a connection termination request
  1453.     acknowledgment from the remote TCP.
  1454.  
  1455.     CLOSED - represents no connection state at all.
  1456.  
  1457.   A TCP connection progresses from one state to another in response to
  1458.   events.  The events are the user calls, OPEN, SEND, RECEIVE, CLOSE,
  1459.   ABORT, and STATUS; the incoming segments, particularly those
  1460.   containing the SYN and FIN flags; and timeouts.
  1461.  
  1462.   The Glossary contains a more complete list of terms and their
  1463.   definitions.
  1464.  
  1465.   The state diagram in figure 6 only illustrates state changes, together
  1466.  
  1467.  
  1468.                                                                [Page 21]
  1469.  
  1470.  
  1471.                                                              August 1979
  1472. Transmission Control Protocol
  1473. Functional Specification
  1474.  
  1475.  
  1476.  
  1477.   with the causing events and resulting actions, but addresses neither
  1478.   error conditions nor actions which are not connected with state
  1479.   changes.  In a later section, more detail is offered with respect to
  1480.   the reaction of the TCP to events.
  1481.  
  1482.  
  1483.  
  1484.  
  1485.  
  1486.  
  1487.  
  1488.  
  1489.  
  1490.  
  1491.  
  1492.  
  1493.  
  1494.  
  1495.  
  1496.  
  1497.  
  1498.  
  1499.  
  1500.  
  1501.  
  1502.  
  1503.  
  1504.  
  1505.  
  1506.  
  1507.  
  1508.  
  1509.  
  1510.  
  1511.  
  1512.  
  1513.  
  1514.  
  1515.  
  1516.  
  1517.  
  1518.  
  1519.  
  1520.  
  1521.  
  1522.  
  1523.  
  1524.  
  1525.  
  1526.  
  1527. [Page 22]                                                               
  1528.  
  1529.  
  1530. August 1979                                                             
  1531.                                            Transmission Control Protocol
  1532.                                                 Functional Specification
  1533.  
  1534.  
  1535.  
  1536.                                     
  1537.                               +---------+ ---------\      active OPEN  
  1538.                               |  CLOSED |            \    -----------  
  1539.                               +---------+<---------\   \   create TCB  
  1540.                                 |     ^              \   \  snd SYN    
  1541.                    passive OPEN |     |   CLOSE        \   \           
  1542.                    ------------ |     | ----------       \   \         
  1543.                     create TCB  |     | delete TCB         \   \       
  1544.                                 V     |                      \   \     
  1545.                               +---------+            CLOSE    |    \   
  1546.                               |  LISTEN |          ---------- |     |  
  1547.                               +---------+          delete TCB |     |  
  1548.                    rcv SYN      |     |     SEND              |     |  
  1549.                   -----------   |     |    -------            |     V  
  1550.  +---------+      snd SYN,ACK  /       \   snd SYN          +---------+
  1551.  |         |<-----------------           ------------------>|         |
  1552.  |   SYN   |                    rcv SYN                     |   SYN   |
  1553.  |   RCVD  |<-----------------------------------------------|   SENT  |
  1554.  |         |                    snd ACK                     |         |
  1555.  |         |------------------           -------------------|         |
  1556.  +---------+   rcv ACK of SYN  \       /  rcv SYN,ACK       +---------+
  1557.    |           --------------   |     |   -----------                  
  1558.    |                  x         |     |     snd ACK                    
  1559.    |                            V     V                                
  1560.    |  CLOSE                   +---------+                              
  1561.    | -------                  |  ESTAB  |                              
  1562.    | snd FIN                  +---------+                              
  1563.    |                   CLOSE    |     |    rcv FIN                     
  1564.    V                  -------   |     |    -------                     
  1565.  +---------+          snd FIN  /       \   snd ACK          +---------+
  1566.  |  FIN    |<-----------------           ------------------>|  CLOSE  |
  1567.  | WAIT-1  |------------------           -------------------|   WAIT  |
  1568.  +---------+          rcv FIN  \       /   CLOSE            +---------+
  1569.    | rcv ACK of FIN   -------   |     |   -------                      
  1570.    | --------------   snd ACK   |     |   snd FIN                      
  1571.    V        x                   V     V                                
  1572.  +---------+                  +---------+                              
  1573.  |FINWAIT-2|                  | CLOSING |                              
  1574.  +---------+                  +---------+                              
  1575.    | rcv FIN                          | rcv ACK of FIN                 
  1576.    | -------    Timeout=2MSL          | --------------                 
  1577.    V snd ACK    ------------          V   delete TCB                   
  1578.  +---------+     delete TCB   +---------+                              
  1579.  |TIME WAIT|----------------->| CLOSED  |                              
  1580.  +---------+                  +---------+                              
  1581.  
  1582.                       TCP Connection State Diagram
  1583.                                Figure 6.
  1584.  
  1585.  
  1586.                                                                [Page 23]
  1587.  
  1588.  
  1589.                                                              August 1979
  1590. Transmission Control Protocol
  1591. Functional Specification
  1592.  
  1593.  
  1594.  
  1595. 3.3.  Sequence Numbers
  1596.  
  1597.   A fundamental notion in the design is that every octet of data sent
  1598.   over a TCP connection has a sequence number.  Since every octet is
  1599.   sequenced, each of them can be acknowledged.  The acknowledgment
  1600.   mechanism employed is cumulative so that an acknowledgment of sequence
  1601.   number X indicates that all octets up to but not including X have been
  1602.   received.  This mechanism allows for straight-forward duplicate
  1603.   detection in the presence of retransmission.
  1604.  
  1605.   It is essential to remember that the actual sequence number space is
  1606.   finite, though very large.  This space ranges from 0 to 2**32 - 1.
  1607.   Since the space is finite, all arithmetic dealing with sequence
  1608.   numbers must be performed modulo 2**32.  This unsigned arithmetic
  1609.   preserves the relationship of sequence numbers as they cycle from
  1610.   2**32 - 1 to 0 again.  There are some subtleties to computer modulo
  1611.   arithmetic, so great care should be taken in programming the
  1612.   comparison of such values.  The typical kinds of sequence number
  1613.   comparisons which the TCP must perform include:
  1614.  
  1615.     (a)  Determining that an acknowledgment refers to some sequence
  1616.          number sent but not yet acknowledged.
  1617.  
  1618.     (b)  Determining that all sequence numbers occupied by a segment
  1619.          have been acknowledged (e.g., to remove the segment from a
  1620.          retransmission queue).
  1621.  
  1622.     (c)  Determining that an incoming segment contains sequence numbers
  1623.          which are expected (i.e., that the segment "overlaps" the
  1624.          receive window).
  1625.  
  1626.   On send connections the following comparisons are needed:
  1627.  
  1628.     older sequence numbers                        newer sequence numbers
  1629.  
  1630.                                     
  1631.         SND.UNA                SEG.ACK                 SND.NXT  
  1632.            |                      |                       |     
  1633.        ----|----XXXXXXX------XXXXXXXXXX---------XXXXXX----|---- 
  1634.            |    |            |    |             |         |     
  1635.                 |            |                  |               
  1636.              Segment 1    Segment 2          Segment 3          
  1637.  
  1638.                       <----- sequence space ----->
  1639.  
  1640.                    Sending Sequence Space Information
  1641.  
  1642.                                Figure 7.
  1643.  
  1644.  
  1645. [Page 24]                                                               
  1646.  
  1647.  
  1648. August 1979                                                             
  1649.                                            Transmission Control Protocol
  1650.                                                 Functional Specification
  1651.  
  1652.  
  1653.  
  1654.     SND.UNA = oldest unacknowledged sequence number
  1655.  
  1656.     SND.NXT = next sequence number to be sent
  1657.  
  1658.     SEG.ACK = acknowledgment (next sequence number expected by the
  1659.               acknowledging TCP)
  1660.  
  1661.     SEG.SEQ = first sequence number of a segment
  1662.  
  1663.     SEG.SEQ+SEG.LEN-1 = last sequence number of a segment
  1664.  
  1665.   An acceptable acknowledgment, SEG.ACK, is one for which the inequality
  1666.   below holds:
  1667.  
  1668.     0 < (SEG.ACK - SND.UNA) =< (SND.NXT - SND.UNA)
  1669.  
  1670.   or:
  1671.  
  1672.     SND.UNA < SEG.ACK =< SND.NXT
  1673.  
  1674.   Note that all arithmetic is modulo 2**32 and that comparisons are
  1675.   unsigned.  "=<" means "less than or equal".
  1676.  
  1677.   Similarly, the determination that a particular segment has been fully
  1678.   acknowledged can be made if the inequality below holds:
  1679.  
  1680.     0 < (SEG.SEQ+SEG.LEN-1 - SND.UNA) < (SEG.ACK - SND.UNA)
  1681.  
  1682.   SEG.LEN is the number of octets occupied by the data in the segment.
  1683.   It is important to note that SEG.LEN must be non-zero; segments which
  1684.   do not occupy any sequence space (e.g., empty acknowledgment segments)
  1685.   are never placed on the retransmission queue, so would not go through
  1686.   this particular test.
  1687.  
  1688.  
  1689.  
  1690.  
  1691.  
  1692.  
  1693.  
  1694.  
  1695.  
  1696.  
  1697.  
  1698.  
  1699.  
  1700.  
  1701.  
  1702.  
  1703.  
  1704.                                                                [Page 25]
  1705.  
  1706.  
  1707.                                                              August 1979
  1708. Transmission Control Protocol
  1709. Functional Specification
  1710.  
  1711.  
  1712.  
  1713.   On receive connections the following comparisons are needed:
  1714.  
  1715.     older sequence numbers                        newer sequence numbers
  1716.  
  1717.                                     
  1718.                 RCV.NXT                         RCV.NXT+RCV.WND 
  1719.                    |                               |            
  1720.        ---------XXX|XXX------XXXXXXXXXX---------XXX|XX--------- 
  1721.                 |  |         |                  |  |            
  1722.                 |            |                  |               
  1723.              Segment 1    Segment 2          Segment 3          
  1724.  
  1725.                       <----- sequence space ----->
  1726.  
  1727.                   Receiving Sequence Space Information
  1728.  
  1729.                                 Figure 8.
  1730.  
  1731.     RCV.NXT = next sequence number expected on incoming segments
  1732.  
  1733.     RCV.NXT+RCV.WND = last sequence number expected on incoming
  1734.         segments, plus one
  1735.  
  1736.     SEG.SEQ = first sequence number occupied by the incoming segment
  1737.  
  1738.     SEG.SEQ+SEG.LEN-1 = last sequence number occupied by the incoming
  1739.         segment
  1740.  
  1741.   A segment is judged to occupy a portion of valid receive sequence
  1742.   space if
  1743.  
  1744.      0 =< (SEG.SEQ+SEG.LEN-1 - RCV.NXT) < (RCV.NXT+RCV.WND - RCV.NXT)
  1745.  
  1746.   SEG.SEQ+SEG.LEN-1 is the last sequence number occupied by the segment;
  1747.   RCV.NXT is the next sequence number expected on an incoming segment;
  1748.   and RCV.NXT+RCV.WND is the right edge of the receive window.
  1749.  
  1750.   Actually, it is a little more complicated than this.  Due to zero
  1751.   windows and zero length segments, we have four cases for the
  1752.   acceptability of an incoming segment:
  1753.  
  1754.  
  1755.  
  1756.  
  1757.  
  1758.  
  1759.  
  1760.  
  1761.  
  1762.  
  1763. [Page 26]                                                               
  1764.  
  1765.  
  1766. August 1979                                                             
  1767.                                            Transmission Control Protocol
  1768.                                                 Functional Specification
  1769.  
  1770.  
  1771.  
  1772.     Segment Receive  Test
  1773.     Length  Window
  1774.     ------- -------  -------------------------------------------
  1775.  
  1776.        0       0     SEG.SEQ = RCV.NXT
  1777.  
  1778.        0      >0     RCV.NXT =< SEG.SEQ < RCV.NXT+RCV.WND
  1779.  
  1780.       >0       0     not acceptable
  1781.  
  1782.       >0      >0     RCV.NXT < SEG.SEQ+SEG.LEN =< RCV.NXT+RCV.WND
  1783.  
  1784.   Note that the acceptance test for a segment, since it requires the end
  1785.   of a segment to lie in the window, is somewhat more restrictive than
  1786.   is absolutely necessary.  If at least the first sequence number of the
  1787.   segment lies in the receive window, or if some part of the segment
  1788.   lies in the receive window, then the segment might be judged
  1789.   acceptable.  Thus, in figure 8, at least segments 1 and 2 are
  1790.   acceptable by the strict rule, and segment 3 may or may not be,
  1791.   depending on the strictness of interpretation of the rule.
  1792.  
  1793.   Note that when the receive window is zero no segments should be
  1794.   acceptable except ACK segments.  Thus, it should be possible for a TCP
  1795.   to maintain a zero receive window while transmitting data and
  1796.   receiving ACKs.
  1797.  
  1798.   We have taken advantage of the numbering scheme to protect certain
  1799.   control information as well.  This is achieved by implicitly including
  1800.   some control flags in the sequence space so they can be retransmitted
  1801.   and acknowledged without confusion (i.e., one and only one copy of the
  1802.   control will be acted upon).  Control information is not physically
  1803.   carried in the segment data space.  Consequently, we must adopt rules
  1804.   for implicitly assigning sequence numbers to control.  The SYN and FIN
  1805.   are the only controls requiring this protection, and these controls
  1806.   are used only at connection opening and closing.  For sequence number
  1807.   purposes, the SYN is considered to occur before the first actual data
  1808.   octet of the segment in which it occurs, while the FIN is considered
  1809.   to occur after the last actual data octet in a segment in which it
  1810.   occurs.  The segment length includes both data and sequence space
  1811.   occupying controls.
  1812.  
  1813.   Initial Sequence Number Selection
  1814.  
  1815.   The protocol places no restriction on a particular connection being
  1816.   used over and over again.  A connection is defined by a pair of
  1817.   sockets.  New instances of a connection will be referred to as
  1818.   incarnations of the connection.  The problem that arises owing to this
  1819.   is -- "how does the TCP identify duplicate segments from previous
  1820.  
  1821.  
  1822.                                                                [Page 27]
  1823.  
  1824.  
  1825.                                                              August 1979
  1826. Transmission Control Protocol
  1827. Functional Specification
  1828.  
  1829.  
  1830.  
  1831.   incarnations of the connection?"  This problem becomes apparent if the
  1832.   connection is being opened and closed in quick succession, or if the
  1833.   connection breaks with loss of memory and is then reestablished.
  1834.  
  1835.   To avoid confusion we must prevent segments from being emitted with
  1836.   sequence numbers which duplicate those which are still in the network.
  1837.   We want to assure this, even if a TCP crashes and loses all knowledge
  1838.   of the sequence numbers it has been using.  When new connections are
  1839.   created, an initial sequence number (ISN) generator is employed which
  1840.   selects a new 32 bit ISN.  The generator is bound to a (possibly
  1841.   fictitious) 32 bit clock whose low order bit is incremented roughly
  1842.   every 4 microseconds.  Thus, the ISN cycles approximately every 4.55
  1843.   hours.  Since we assume that segments will stay in the network no more
  1844.   than tens of seconds or minutes, at worst, we can reasonably assume
  1845.   that ISN's will be unique.
  1846.  
  1847.   For each connection there is a send sequence number and a receive
  1848.   sequence number.  The initial send sequence number (ISS) is chosen by
  1849.   the data sending TCP, and the initial receive sequence number (IRS) is
  1850.   learned during the connection establishing procedure.
  1851.  
  1852.   For a connection to be established or initialized, the two TCPs must
  1853.   synchronize on each other's initial sequence numbers.  This is done in
  1854.   an exchange of connection establishing messages carrying a control bit
  1855.   called "SYN" (for synchronize) and the initial sequence numbers.  As a
  1856.   shorthand, messages carrying the SYN bit are also called "SYNs".
  1857.   Hence, the solution requires a suitable mechanism for picking an
  1858.   initial sequence number and a slightly involved handshake to exchange
  1859.   the ISN's.  A "three way handshake" is necessary because sequence
  1860.   numbers are not tied to a global clock in the network, and TCPs may
  1861.   have different mechanisms for picking the ISN's.  The receiver of the
  1862.   first SYN has no way of knowing whether the segment was an old delayed
  1863.   one or not, unless it remembers the last sequence number used on the
  1864.   connection (which is not always possible), and so it must ask the
  1865.   sender to verify this SYN.
  1866.  
  1867.   The "three way handshake" and the advantages of a "clock-driven"
  1868.   scheme are discussed in [3].
  1869.  
  1870.   Knowing When to Keep Quiet
  1871.  
  1872.   To be sure that a TCP does not create a segment that carries a
  1873.   sequence number which may be duplicated by an old segment remaining in
  1874.   the network, the TCP must keep quiet for a maximum segment lifetime
  1875.   (MSL) before assigning any sequence numbers upon starting up or
  1876.   recovering from a crash in which memory of sequence numbers in use was
  1877.   lost.  For this specification the MSL is taken to be 2 minutes.  This
  1878.   is an engineering choice, and may be changed if experience indicates
  1879.  
  1880.  
  1881. [Page 28]                                                               
  1882.  
  1883.  
  1884. August 1979                                                             
  1885.                                            Transmission Control Protocol
  1886.                                                 Functional Specification
  1887.  
  1888.  
  1889.  
  1890.   it is desirable to do so.  Note that if a TCP is reinitialized in some
  1891.   sense, yet retains its memory of sequence numbers in use, then it need
  1892.   not wait at all; it must only be sure to use sequence numbers larger
  1893.   than those recently used.
  1894.  
  1895.   It should be noted that this strategy does not protect against
  1896.   spoofing or other replay type duplicate message problems.
  1897.  
  1898. 3.4.  Establishing a connection
  1899.  
  1900.   The "three-way handshake" is essentially a unidirectional attempt to
  1901.   establish a connection, i.e., there is an initiator and a responder.
  1902.   The TCP can also establish a connection when a simultaneous initiation
  1903.   occurs.  A simultaneous attempt occurs when one TCP receives a "SYN"
  1904.   segment which carries no acknowledgment after it has sent a "SYN".  Of
  1905.   course, the arrival of an old duplicate "SYN" segment can potentially
  1906.   make it appear, to the recipient, that a simultaneous connection
  1907.   initiation is in progress.  Proper use of "reset" segments can
  1908.   disambiguate these cases.  Several examples of connection initiation
  1909.   are offered below.  Although these examples do not show connection
  1910.   synchronization using data-carrying segments, this is perfectly
  1911.   legitimate, so long as the receiving TCP doesn't deliver the data to
  1912.   the user until it is clear the data is valid (i.e., the data must be
  1913.   buffered at the receiver until the connection reaches the ESTABLISHED
  1914.   state).  The three-way handshake reduces the possibility of false
  1915.   connections.  It is the implementation of a trade-off between memory
  1916.   and messages to provide information for this checking.
  1917.  
  1918.   The simplest three-way handshake is shown in figure 9 below.  The
  1919.   figures should be interpreted in the following way.  Each line is
  1920.   numbered for reference purposes.  Right arrows (-->) indicate
  1921.   departure of a TCP segment from TCP A to TCP B, or arrival of a
  1922.   segment at B from A.  Left arrows (<--), indicate the reverse.
  1923.   Ellipsis (...) indicates a segment which is still in the network
  1924.   (delayed).  An "XXX" indicates a segment which is lost or rejected.
  1925.   Comments appear in parentheses.  TCP states represent the state AFTER
  1926.   the departure or arrival of the segment (whose contents are shown in
  1927.   the center of each line).  Segment contents are shown in abbreviated
  1928.   form, with sequence number, control flags, and ACK field.  Other
  1929.   fields such as window, addresses, lengths, and text have been left out
  1930.   in the interest of clarity.
  1931.  
  1932.  
  1933.  
  1934.  
  1935.  
  1936.  
  1937.  
  1938.  
  1939.  
  1940.                                                                [Page 29]
  1941.  
  1942.  
  1943.                                                              August 1979
  1944. Transmission Control Protocol
  1945. Functional Specification
  1946.  
  1947.  
  1948.  
  1949.   
  1950.  
  1951.       TCP A                                                TCP B
  1952.  
  1953.   1.  CLOSED                                               LISTEN
  1954.  
  1955.   2.  SYN-SENT    --> <SEQ=100><CTL=SYN>               --> SYN-RECEIVED
  1956.  
  1957.   3.  ESTABLISHED <-- <SEQ=300><ACK=101><CTL=SYN,ACK>  <-- SYN-RECEIVED
  1958.  
  1959.   4.  ESTABLISHED --> <SEQ=101><ACK=301><CTL=ACK>       --> ESTABLISHED
  1960.  
  1961.   5.  ESTABLISHED --> <SEQ=101><ACK=301><CTL=ACK><DATA> --> ESTABLISHED
  1962.  
  1963.           Basic 3-Way Handshake for Connection Synchronization
  1964.  
  1965.                                 Figure 9.
  1966.  
  1967.   In line 2 of figure 9, TCP A begins by sending a SYN segment
  1968.   indicating that it will use sequence numbers starting with sequence
  1969.   number 100.  In line 3, TCP B sends a SYN and acknowledges the SYN it
  1970.   received from TCP A.  Note that the acknowledgment field indicates TCP
  1971.   B is now expecting to hear sequence 101, acknowledging the SYN which
  1972.   occupied sequence 100.
  1973.  
  1974.   At line 4, TCP A responds with an empty segment containing an ACK for
  1975.   TCP B's SYN; and in line 5, TCP A sends some data.  Note that the
  1976.   sequence number of the segment in line 5 is the same as in line 4
  1977.   because the ACK does not occupy sequence number space (if it did, we
  1978.   would wind up ACKing ACK's!).
  1979.  
  1980.   Simultaneous initiation is only slightly more complex, as is shown in
  1981.   figure 10.  Each TCP cycles from CLOSED to SYN-SENT to SYN-RECEIVED to
  1982.   ESTABLISHED.
  1983.  
  1984.   The principle reason for the three-way handshake is to prevent old
  1985.   duplicate connection initiations from causing confusion.  To deal with
  1986.   this, a special control message, reset, has been devised.  A TCP which
  1987.   receives a reset message first verifies that the ACK field of the
  1988.   reset acknowledges something the TCP sent (otherwise, the message is
  1989.   ignored).  If the receiving TCP is in a  non-synchronized state (i.e.,
  1990.   SYN-SENT, SYN-RECEIVED), it returns to LISTEN on receiving an
  1991.   acceptable reset.  If the TCP is in one of the synchronized states
  1992.   (ESTABLISHED, FIN-WAIT-1, FIN-WAIT-2, TIME-WAIT, CLOSE-WAIT, CLOSING),
  1993.   it aborts the connection and informs its user.  We discuss this latter
  1994.   case under "half-open" connections below.
  1995.  
  1996.  
  1997.  
  1998.  
  1999. [Page 30]                                                               
  2000.  
  2001.  
  2002. August 1979                                                             
  2003.                                            Transmission Control Protocol
  2004.                                                 Functional Specification
  2005.  
  2006.  
  2007.  
  2008.   
  2009.  
  2010.       TCP A                                        TCP B
  2011.  
  2012.   1.  CLOSED                                       CLOSED
  2013.  
  2014.   2.  SYN-SENT     --> <SEQ=100><CTL=SYN>          ...
  2015.  
  2016.   3.  SYN-RECEIVED <-- <SEQ=300><CTL=SYN>          <-- SYN-SENT
  2017.  
  2018.   4.               ... <SEQ=100><CTL=SYN>          --> SYN-RECEIVED
  2019.  
  2020.   5.  SYN-RECEIVED --> <SEQ=101><ACK=301><CTL=ACK> ...
  2021.  
  2022.   6.  ESTABLISHED  <-- <SEQ=301><ACK=101><CTL=ACK> <-- SYN-RECEIVED
  2023.  
  2024.   7.               ... <SEQ=101><ACK=301><CTL=ACK> --> ESTABLISHED
  2025.  
  2026.                 Simultaneous Connection Synchronization
  2027.  
  2028.                                Figure 10.
  2029.  
  2030.   
  2031.  
  2032.       TCP A                                                TCP B
  2033.  
  2034.   1.  CLOSED                                               LISTEN
  2035.  
  2036.   2.  SYN-SENT    --> <SEQ=100><CTL=SYN>               ...
  2037.  
  2038.   3.  (duplicate) ... <SEQ=1000><CTL=SYN>              --> SYN-RECEIVED
  2039.  
  2040.   4.  SYN-SENT    <-- <SEQ=300><ACK=1001><CTL=SYN,ACK> <-- SYN-RECEIVED
  2041.  
  2042.   5.  SYN-SENT    --> <SEQ=1001><CTL=RST>              --> LISTEN
  2043.                                                            (ACK is ok)
  2044.  
  2045.   6.              ... <SEQ=100><CTL=SYN>               --> SYN-RECEIVED
  2046.  
  2047.   7.  SYN-SENT    <-- <SEQ=400><ACK=101><CTL=SYN,ACK>  <-- SYN-RECEIVED
  2048.  
  2049.   8.  ESTABLISHED --> <SEQ=101><ACK=401><CTL=ACK>      --> ESTABLISHED
  2050.  
  2051.                     Recovery from Old Duplicate SYN
  2052.  
  2053.                                Figure 11.
  2054.  
  2055.   As a simple example of recovery from old duplicates, consider
  2056.  
  2057.  
  2058.                                                                [Page 31]
  2059.  
  2060.  
  2061.                                                              August 1979
  2062. Transmission Control Protocol
  2063. Functional Specification
  2064.  
  2065.  
  2066.  
  2067.   figure 11.  At line 3, an old duplicate SYN arrives at TCP B.  TCP B
  2068.   cannot tell that this is an old duplicate, so it responds normally
  2069.   (line 4).  TCP A detects that the ACK field is incorrect and returns a
  2070.   RST (reset) with its SEQ field selected to make the segment
  2071.   believable.  TCP B, on receiving the RST, returns to the LISTEN state.
  2072.   When the original SYN (pun intended) finally arrives at line 6, the
  2073.   synchronization proceeds normally.  If the SYN at line 6 had arrived
  2074.   before the RST, a more complex exchange might have occurred with RST's
  2075.   sent in both directions.
  2076.  
  2077.   Half-Open Connections and Other Anomalies
  2078.  
  2079.   An established connection is said to be  "half-open" if one of the
  2080.   TCPs has closed or aborted the connection at its end without the
  2081.   knowledge of the other, or if the two ends of the connection have
  2082.   become desynchronized owing to a crash that resulted in loss of
  2083.   memory.  Such connections will automatically become reset if an
  2084.   attempt is made to send data in either direction.  However, half-open
  2085.   connections are expected to be unusual, and the recovery procedure is
  2086.   mildly involved.
  2087.  
  2088.   If at site A the connection no longer exists, then an attempt by the
  2089.   user at site B to send any data on it will result in the site B TCP
  2090.   receiving a reset control message.  Such a message should indicate to
  2091.   the site B TCP that something is wrong, and it is expected to abort
  2092.   the connection.
  2093.  
  2094.   Assume that two user processes A and B are communicating with one
  2095.   another when a crash occurs causing loss of memory to A's TCP.
  2096.   Depending on the operating system supporting A's TCP, it is likely
  2097.   that some error recovery mechanism exists.  When the TCP is up again,
  2098.   A is likely to start again from the beginning or from a recovery
  2099.   point.  As a result, A will probably try to OPEN the connection again
  2100.   or try to SEND on the connection it believes open.  In the latter
  2101.   case, it receives the error message "connection not open" from the
  2102.   local (A's) TCP.  In an attempt to establish the connection, A's TCP
  2103.   will send a segment containing SYN.  This scenario leads to the
  2104.   example shown in figure 12.  After TCP A crashes, the user attempts to
  2105.   re-open the connection.  TCP B, in the meantime, thinks the connection
  2106.   is open.
  2107.  
  2108.  
  2109.  
  2110.  
  2111.  
  2112.  
  2113.  
  2114.  
  2115.  
  2116.  
  2117. [Page 32]                                                               
  2118.  
  2119.  
  2120. August 1979                                                             
  2121.                                            Transmission Control Protocol
  2122.                                                 Functional Specification
  2123.  
  2124.  
  2125.  
  2126.   
  2127.  
  2128.       TCP A                                           TCP B
  2129.  
  2130.   1.  (CRASH)                               (send 300,receive 100)
  2131.  
  2132.   2.  CLOSED                                           ESTABLISHED
  2133.  
  2134.   3.  SYN-SENT --> <SEQ=400><CTL=SYN>              --> (??)
  2135.  
  2136.   4.  (!!)     <-- <SEQ=300><ACK=100><CTL=ACK>     <-- ESTABLISHED
  2137.  
  2138.   5.  SYN-SENT --> <SEQ=100><CTL=RST>              --> (Abort!!)
  2139.  
  2140.   6.                                                   CLOSED
  2141.  
  2142.   7.  SYN-SENT --> <SEQ=400><CTL=SYN>              --> CLOSED
  2143.  
  2144.   8.  (Abort!!)<-- <SEQ=xxx><ACK=401><CTL=RST,ACK> <-- CLOSED
  2145.  
  2146.   9.  CLOSED                                           CLOSED
  2147.  
  2148.                      Half-Open Connection Discovery
  2149.  
  2150.                                Figure 12.
  2151.  
  2152.   When the SYN arrives at line 3, TCP B, being in a synchronized state,
  2153.   responds with an acknowledgment indicating what sequence it next
  2154.   expects to hear (ACK 100).  TCP A sees that this segment does not
  2155.   acknowledge anything it sent and, being unsynchronized, sends a reset
  2156.   (RST) because it has detected a half-open connection.  TCP B aborts at
  2157.   line 5.  TCP A will continue to retransmit its SYN; and if the user at
  2158.   TCP B re-opens the connection, eventually everything will work out.
  2159.   In the figure TCP B does not reopen the connection, and in line 8
  2160.   sends a reset to reject the offered connection.
  2161.  
  2162.   An interesting alternative case occurs when TCP A crashes and TCP B
  2163.   tries to send data on what it thinks is a synchronized connection.
  2164.   This is illustrated in figure 13.  In this case, the data arriving at
  2165.   TCP A from TCP B (line 2) is unacceptable because no such connection
  2166.   exists, so TCP A sends a RST.  The RST is acceptable so TCP B
  2167.   processes it and aborts the connection.
  2168.  
  2169.  
  2170.  
  2171.  
  2172.  
  2173.  
  2174.  
  2175.  
  2176.                                                                [Page 33]
  2177.  
  2178.  
  2179.                                                              August 1979
  2180. Transmission Control Protocol
  2181. Functional Specification
  2182.  
  2183.  
  2184.  
  2185.   
  2186.  
  2187.         TCP A                                              TCP B
  2188.  
  2189.   1.  (CRASH)                                   (send 300,receive 100)
  2190.  
  2191.   2.  (??)    <-- <SEQ=300><ACK=100><DATA=10><CTL=ACK> <-- ESTABLISHED
  2192.  
  2193.   3.          --> <SEQ=100><CTL=RST>                   --> (ABORT!!)
  2194.  
  2195.            Active Side Causes Half-Open Connection Discovery
  2196.  
  2197.                                Figure 13.
  2198.  
  2199.   In figure 14, we find the two TCPs A and B with passive connections
  2200.   waiting for SYN.  An old duplicate arriving at TCP B (line 2) stirs B
  2201.   into action.  A SYN-ACK is returned (line 3) and causes TCP A to
  2202.   generate a RST (the ACK in line 3 is not acceptable).  TCP B accepts
  2203.   the reset and returns to its passive LISTEN state.
  2204.  
  2205.   
  2206.  
  2207.       TCP A                                         TCP B
  2208.  
  2209.   1.  LISTEN                                        LISTEN
  2210.  
  2211.   2.       ... <SEQ=Z><CTL=SYN>                -->  SYN-RECEIVED
  2212.  
  2213.   3.  (??) <-- <SEQ=X><ACK=Z+1><CTL=SYN,ACK>   <--  SYN-RECEIVED
  2214.  
  2215.   4.       --> <SEQ=Z+1><CTL=RST>              -->  (return to LISTEN!)
  2216.  
  2217.   5.  LISTEN                                        LISTEN
  2218.  
  2219.        Old Duplicate SYN Initiates a Reset on two Passive Sockets
  2220.  
  2221.                                Figure 14.
  2222.  
  2223.   A variety of other cases are possible, all of which are accounted for
  2224.   by the following rules for RST generation and processing.
  2225.  
  2226.   Reset Generation
  2227.  
  2228.   As a general rule, reset (RST) should be sent whenever a segment
  2229.   arrives which apparently is not intended for the current or a future
  2230.   incarnation of the connection.  A reset should not be sent if it is
  2231.   not clear that this is the case.  Thus, if any segment arrives for a
  2232.   nonexistent connection, a reset should be sent.  If a segment ACKs
  2233.  
  2234.  
  2235. [Page 34]                                                               
  2236.  
  2237.  
  2238. August 1979                                                             
  2239.                                            Transmission Control Protocol
  2240.                                                 Functional Specification
  2241.  
  2242.  
  2243.  
  2244.   something which has never been sent on the current connection, then
  2245.   one of the following two cases applies.
  2246.  
  2247.   1.  If the connection is in any non-synchronized state (LISTEN,
  2248.   SYN-SENT, SYN-RECEIVED) or if the connection does not exist, a reset
  2249.   (RST) should be formed and sent for any segment that acknowledges
  2250.   something not yet sent.  The RST should take its SEQ field from the
  2251.   ACK field of the offending segment (if the ACK control bit was set),
  2252.   and its ACK bit should be reset (zero), except to refuse a initial
  2253.   SYN.
  2254.  
  2255.   2.  If the connection is in a synchronized state (ESTABLISHED,
  2256.   FIN-WAIT-1, FIN-WAIT-2, TIME-WAIT, CLOSE-WAIT, CLOSING), any
  2257.   unacceptable segment should elicit only an empty acknowledgment
  2258.   segment containing the current send-sequence number and an
  2259.   acknowledgment indicating the next sequence number expected to be
  2260.   received.
  2261.  
  2262.   Reset Processing
  2263.  
  2264.   All reset (RST) segments are validated by checking their SEQ-fields.
  2265.   A reset is valid if it's sequence number is the next expected sequence
  2266.   number.  In the case of a RST received in response to an initial SYN
  2267.   any sequence number is acceptable if the ACK field acknowledges the
  2268.   SYN.
  2269.  
  2270.   The receiver of a RST first validates it, then changes state.  If the
  2271.   receiver was in the LISTEN state, it ignores it.  If the receiver was
  2272.   in SYN-RECEIVED state and had previously been in the LISTEN state,
  2273.   then the receiver returns to the LISTEN state, otherwise the receiver
  2274.   aborts the connection and goes to the CLOSED state.  If the receiver
  2275.   was in any other state, it aborts the connection and advises the user
  2276.   and goes to the CLOSED state.
  2277.  
  2278. 3.5.  Closing a Connection
  2279.  
  2280.   CLOSE is an operation meaning "I have no more data to send."  The
  2281.   notion of closing a full-duplex connection is subject to ambiguous
  2282.   interpretation, of course, since it may not be obvious how to treat
  2283.   the receiving side of the connection.  We have chosen to treat CLOSE
  2284.   in a simplex fashion.  The user who CLOSEs may continue to RECEIVE
  2285.   until he is told that the other side has CLOSED also.  Thus, a program
  2286.   could initiate several SENDs followed by a CLOSE, and then continue to
  2287.   RECEIVE until signaled that a RECEIVE failed because the other side
  2288.   has CLOSED.  We assume that the TCP will unilaterally inform a user,
  2289.   even if no RECEIVEs are outstanding, that the other side has closed,
  2290.   so the user can terminate his side gracefully.  A TCP will reliably
  2291.   deliver all buffers SENT before the connection was CLOSED so a user
  2292.  
  2293.  
  2294.                                                                [Page 35]
  2295.  
  2296.  
  2297.                                                              August 1979
  2298. Transmission Control Protocol
  2299. Functional Specification
  2300.  
  2301.  
  2302.  
  2303.   who expects no data in return need only wait to hear the connection
  2304.   was CLOSED successfully to know that all his data was received at the
  2305.   destination TCP.
  2306.  
  2307.   There are essentially three cases:
  2308.  
  2309.     1) The user initiates by telling the TCP to CLOSE the connection
  2310.  
  2311.     2) The remote TCP initiates by sending a FIN control signal
  2312.  
  2313.     3) Both users CLOSE simultaneously
  2314.  
  2315.   Case 1:  Local user initiates the close
  2316.  
  2317.     In this case, a FIN segment can be constructed and placed on the
  2318.     outgoing segment queue.  No further SENDs from the user will be
  2319.     accepted by the TCP, and it enters the FIN-WAIT-1 state.  RECEIVEs
  2320.     are allowed in this state.  All segments preceding and including FIN
  2321.     will be retransmitted until acknowledged.  When the other TCP has
  2322.     both acknowledged the FIN and sent a FIN of its own, the first TCP
  2323.     can ACK this FIN.  It should be noted that a TCP receiving a FIN
  2324.     will ACK but not send its own FIN until its user has CLOSED the
  2325.     connection also.
  2326.  
  2327.   Case 2:  TCP receives a FIN from the network
  2328.  
  2329.     If an unsolicited FIN arrives from the network, the receiving TCP
  2330.     can ACK it and tell the user that the connection is closing.  The
  2331.     user should respond with a CLOSE, upon which the TCP can send a FIN
  2332.     to the other TCP.  The TCP then waits until its own FIN is
  2333.     acknowledged whereupon it deletes the connection.  If an ACK is not
  2334.     forthcoming, after a timeout the connection is aborted and the user
  2335.     is told.
  2336.  
  2337.   Case 3:  both users close simultaneously
  2338.  
  2339.     A simultaneous CLOSE by users at both ends of a connection causes
  2340.     FIN segments to be exchanged.  When all segments preceding the FINs
  2341.     have been processed and acknowledged, each TCP can ACK the FIN it
  2342.     has received.  Both will, upon receiving these ACKs, delete the
  2343.     connection.
  2344.  
  2345.  
  2346.  
  2347.  
  2348.  
  2349.  
  2350.  
  2351.  
  2352.  
  2353. [Page 36]                                                               
  2354.  
  2355.  
  2356. August 1979                                                             
  2357.                                            Transmission Control Protocol
  2358.                                                 Functional Specification
  2359.  
  2360.  
  2361.  
  2362.   
  2363.  
  2364.       TCP A                                                TCP B
  2365.  
  2366.   1.  ESTABLISHED                                          ESTABLISHED
  2367.  
  2368.   2.  (Close)
  2369.       FIN-WAIT-1  --> <SEQ=100><CTL=FIN>               --> CLOSE-WAIT
  2370.  
  2371.   3.  FIN-WAIT-2  <-- <SEQ=300><ACK=101><CTL=ACK>      <-- CLOSE-WAIT
  2372.  
  2373.   4.                                                       (Close)
  2374.       TIME-WAIT   <-- <SEQ=301><CTL=FIN>               <-- CLOSING
  2375.  
  2376.   5.  TIME-WAIT   --> <SEQ=100><ACK=301><CTL=ACK>      --> CLOSED
  2377.  
  2378.   6.  (2 MSL)
  2379.       CLOSED
  2380.  
  2381.                          Normal Close Sequence
  2382.  
  2383.                                Figure 15.
  2384.  
  2385.   
  2386.  
  2387.       TCP A                                                TCP B
  2388.  
  2389.   1.  ESTABLISHED                                          ESTABLISHED
  2390.  
  2391.   2.  (Close)                                              (Close)
  2392.       FIN-WAIT-1  --> <SEQ=100><CTL=FIN>               --> FIN-WAIT-1
  2393.                   <-- <SEQ=300><CTL=FIN>               <--
  2394.  
  2395.   3.  CLOSING     --> <SEQ=100><ACK=301><CTL=ACK>      --> CLOSING
  2396.                   <-- <SEQ=300><ACK=101><CTL=ACK>      <--
  2397.  
  2398.   4.  CLOSED                                               CLOSED
  2399.  
  2400.                       Simultaneous Close Sequence
  2401.  
  2402.                                Figure 16.
  2403.  
  2404.  
  2405.  
  2406.  
  2407.  
  2408.  
  2409.  
  2410.  
  2411.  
  2412.                                                                [Page 37]
  2413.  
  2414.  
  2415.                                                              August 1979
  2416. Transmission Control Protocol
  2417. Functional Specification
  2418.  
  2419.  
  2420.  
  2421. 3.6.  Data Communication
  2422.  
  2423.   Once the connection is established data is communicated by the
  2424.   exchange of segments.  Because segments may be lost due to errors
  2425.   (checksum test failure), or network congestion, TCP uses
  2426.   retransmission (after a timeout) to ensure delivery of every segment.
  2427.   Duplicate segments may arrive due to network or TCP retransmission.
  2428.   As discussed in the section on sequence numbers the TCP performs
  2429.   certain tests on the sequence and acknowledgment numbers in the
  2430.   segments to verify their acceptability.
  2431.  
  2432.   The sender of data keeps track of the next sequence number to use in
  2433.   the variable SND.NXT.  The receiver of data keeps track of the next
  2434.   sequence number to expect in the variable RCV.NXT.  The sender of data
  2435.   keeps track of the oldest unacknowledged sequence number in the
  2436.   variable SND.UNA.  If the data flow is momentarily idle and all data
  2437.   sent has been acknowledged then the three variables will be equal.
  2438.  
  2439.   When the sender creates a segment and transmits it the sender advances
  2440.   SND.NXT.  When the receiver accepts a segment it advances RCV.NXT and
  2441.   sends an acknowledgment.  When the data sender receives an
  2442.   acknowledgment it advances SND.UNA.  The extent to which the values of
  2443.   these variables differ is a measure of the delay in the communication.
  2444.  
  2445.   Normally the amount by which the variables are advanced is the length
  2446.   of the data in the segment.  However, when letters are used there are
  2447.   special provisions for coordination the sequence numbers, the letter
  2448.   boundaries, and the receive buffer boundaries.
  2449.  
  2450.   End of Letter Sequence Number Adjustments
  2451.  
  2452.   There is provision in TCP for the receiver of data to optionally
  2453.   communicate to the sender of data on a connection at the time of the
  2454.   connection synchronization the receiver's buffer size.  If this is
  2455.   done the receiver must use this fixed size of buffers for the lifetime
  2456.   of the connection.  If a buffer size is communicated then there is a
  2457.   coordination between receive buffers, letters, and sequence numbers.
  2458.  
  2459.   Each time a buffer is completed either due to being filled or due to
  2460.   an end of letter, the sequence number is incremented through the end
  2461.   of that buffer.
  2462.  
  2463.   That is, whenever an EOL is transmitted, the sender advances its send
  2464.   sequence number, SND.NXT, by an amount sufficient to consume all the
  2465.   unused space in the receiver's buffer.  The amount of space consumed
  2466.   in this fashion is subtracted from the send window just as is the
  2467.   space consumed by actual data.
  2468.  
  2469.  
  2470.  
  2471. [Page 38]                                                               
  2472.  
  2473.  
  2474. August 1979                                                             
  2475.                                            Transmission Control Protocol
  2476.                                                 Functional Specification
  2477.  
  2478.  
  2479.  
  2480.   And, whenever an EOL is received, the receiver advances its receive
  2481.   sequence number, RCV.NXT, by an amount sufficient to consume all the
  2482.   unused space in the receiver's buffer.  The amount of space consumed
  2483.   in this fashion is subtracted from the receive window just as is the
  2484.   space consumed by actual data.
  2485.  
  2486.     older sequence numbers                        newer sequence numbers
  2487.  
  2488.             |           Buffer 1            |   Buffer 2       
  2489.             |                               |                  
  2490.         ----+-------------------------------+----------------- 
  2491.             XXXXXXXXXXXXXXXXXXXXX+++++++++++                   
  2492.             |                    |          |                  
  2493.             |<-----SEG.LEN------>|          |                  
  2494.             |                    |          |                  
  2495.             |                    |          |                  
  2496.          SEG.SEQ                 A          B                  
  2497.  
  2498.                     XXX - data octets from segment 
  2499.                     +++ - phantom data             
  2500.  
  2501.                       <----- sequence space ----->
  2502.  
  2503.                         End of Letter Adjustment
  2504.  
  2505.                                Figure 17.
  2506.  
  2507.   In the case illustrated above, if the segment does not carry an EOL
  2508.   flag, the next value of SND.NXT or RCV.NXT will be A.  If it does
  2509.   carry an EOL flag, the next value will be B.
  2510.  
  2511.   The exchange of buffer size and sequencing information is done in
  2512.   units of octets.  If no buffer size is stated, then the buffer size is
  2513.   assumed to be 1 octet.  The receiver tells the sender the size of the
  2514.   buffer in a SYN segment that contains the 16 bit buffer size data in
  2515.   an option field in the TCP header.
  2516.  
  2517.   Each EOL advances the sequence number (SN) to the next buffer boundary
  2518.  
  2519.     While LBB < SEG.SEQ+SEG.LEN
  2520.     Do LBB <- LBB + BS End
  2521.     SN <- LBB
  2522.  
  2523.     where LBB is the Last Buffer Beginning, and BS is the buffer size.
  2524.  
  2525.   The CLOSE user call implies an end of letter, as does the FIN control
  2526.   flag in an incoming segment.
  2527.  
  2528.  
  2529.  
  2530.                                                                [Page 39]
  2531.  
  2532.  
  2533.                                                              August 1979
  2534. Transmission Control Protocol
  2535. Functional Specification
  2536.  
  2537.  
  2538.  
  2539.   The Communication of Urgent Information
  2540.  
  2541.   The objective of the TCP urgent mechanism is to allow the sending user
  2542.   to stimulate the receiving user to accept some urgent data and to
  2543.   permit the receiving TCP to indicate to the receiving user when all
  2544.   the currently known urgent data has been received by the user.
  2545.  
  2546.   This mechanism permits a point in the data stream to be designated as
  2547.   the end of "urgent" information.  Whenever this point is in advance of
  2548.   the receive sequence number (RCV.NXT) at the receiving TCP, that TCP
  2549.   should tell the user to go into "urgent mode"; when the receive
  2550.   sequence number catches up to the urgent pointer, the TCP should tell
  2551.   user to go into "normal mode".  If the urgent pointer is updated while
  2552.   the user is in "read fast" mode, the update will be invisible to the
  2553.   user.
  2554.  
  2555.   The method employs a urgent field which is carried in all segments
  2556.   transmitted.  The URG control flag indicates that the urgent field is
  2557.   meaningful and should be added to the segment sequence number to yield
  2558.   the urgent pointer.  The absence of this flag indicates that the
  2559.   urgent pointer has not changed.
  2560.  
  2561.   To send an urgent indication the user must also send at least one data
  2562.   octet.  If the sending user also indicates end of letter, timely
  2563.   delivery of the urgent information to the destination process is
  2564.   enhanced.
  2565.  
  2566.   Managing the Window
  2567.  
  2568.   The window sent in each segment indicates the range of sequence number
  2569.   the sender of the window (the data receiver) is currently prepared to
  2570.   accept.  There is an assumption that this is somehow related to to the
  2571.   currently available data buffer space available for this connection.
  2572.  
  2573.   Indicating a large window encourages transmissions.  If more data
  2574.   arrives than can be accepted, this will result in excessive
  2575.   retransmissions, adding unnecessarily to the load on the network and
  2576.   the TCPs.  Indicating a small window may restrict the transmission of
  2577.   data to the point of introducing a round trip delay between each new
  2578.   segment transmitted.
  2579.  
  2580.   The mechanisms provided allow a TCP to advertise a large window and to
  2581.   subsequently advertise a much smaller window without having accepted
  2582.   that much data.  This, so called "shrinking the window," is strongly
  2583.   discouraged.  The robustness principle dictates that TCPs will not
  2584.   shrink the window themselves, but will be prepared for such behavior
  2585.   on the part of other TCPs.
  2586.  
  2587.  
  2588.  
  2589. [Page 40]                                                               
  2590.  
  2591.  
  2592. August 1979                                                             
  2593.                                            Transmission Control Protocol
  2594.                                                 Functional Specification
  2595.  
  2596.  
  2597.  
  2598.   The sending TCP must be prepared to accept and send at least one octet
  2599.   of new data even if the send window is zero.  The sending TCP should
  2600.   regularly retransmit to the receiving TCP even when the window is
  2601.   zero.  Two minutes is recommended for the retransmission interval when
  2602.   the window is zero.  This retransmission is essential to guarantee
  2603.   that when either TCP has a zero window the re-opening of the window
  2604.   will be reliably reported to the other.
  2605.  
  2606.   Users must keep reading connections they close for sending until the
  2607.   TCP says no more data.
  2608.  
  2609.   In a connection with a one-way data flow, the window information will
  2610.   be carried in acknowledgment segments that all have the same sequence
  2611.   number so there will be no way to reorder them if they arrive out of
  2612.   order.  This is not a serious problem, but it will allow the window
  2613.   information to be on occasion temporarily based on old reports from
  2614.   the data receiver.
  2615.  
  2616. 3.7.  Interfaces
  2617.  
  2618.   There are of course two interfaces of concern:  the user/TCP interface
  2619.   and the TCP/network interface.  We have a fairly elaborate model of
  2620.   the user/TCP interface, but only a sketch of the interface to the
  2621.   lower level protocol module.
  2622.  
  2623.   User/TCP Interface
  2624.  
  2625.     The functional description of user commands to the TCP is, at best,
  2626.     fictional, since every operating system will have different
  2627.     facilities.  Consequently, we must warn readers that different TCP
  2628.     implementations may have different user interfaces.  However, all
  2629.     TCPs must provide a certain minimum set of services to guarantee
  2630.     that all TCP implementations can support the same protocol
  2631.     hierarchy.  This section specifies the functional interfaces
  2632.     required of all TCP implementations.
  2633.  
  2634.     TCP User Commands
  2635.  
  2636.       The following sections functionally characterize a USER/TCP
  2637.       interface.  The notation used is similar to most procedure or
  2638.       function calls in high level languages, but this usage is not
  2639.       meant to rule out trap type service calls (e.g., SVCs, UUOs,
  2640.       EMTs).
  2641.  
  2642.       The user commands described below specify the basic functions the
  2643.       TCP must perform to support interprocess communication.
  2644.       Individual implementations should define their own exact format,
  2645.       and may provide combinations or subsets of the basic functions in
  2646.  
  2647.  
  2648.                                                                [Page 41]
  2649.  
  2650.  
  2651.                                                              August 1979
  2652. Transmission Control Protocol
  2653. Functional Specification
  2654.  
  2655.  
  2656.  
  2657.       single calls.  In particular, some implementations may wish to
  2658.       automatically OPEN a connection on the first SEND or RECEIVE
  2659.       issued by the user for a given connection.
  2660.  
  2661.       In providing interprocess communication facilities, the TCP must
  2662.       not only accept commands, but must also return information to the
  2663.       processes it serves.  The latter consists of:
  2664.  
  2665.         (a) general information about a connection (e.g., interrupts,
  2666.         remote close, binding of unspecified foreign socket).
  2667.  
  2668.         (b) replies to specific user commands indicating success or
  2669.         various types of failure.
  2670.  
  2671.       Although the means for signaling user processes and the exact
  2672.       format of replies will vary from one implementation to another, it
  2673.       would promote common understanding and testing if a common set of
  2674.       codes were adopted.  Such a set of event codes is described below.
  2675.  
  2676.       Open
  2677.  
  2678.         Format:  OPEN (local port, foreign socket, active/passive
  2679.         [, buffer size] [, timeout]) -> local connection name
  2680.  
  2681.         We assume that the local TCP is aware of the identity of the
  2682.         processes it serves and will check the authority of the process
  2683.         to use the connection specified.  Depending upon the
  2684.         implementation of the TCP, the local network and TCP identifiers
  2685.         for the source address will either be supplied by the TCP or by
  2686.         the processes that serve it (e.g., the program which interfaces
  2687.         the TCP network).  These considerations are the result of
  2688.         concern about security, to the extent that no TCP be able to
  2689.         masquerade as another one, and so on.  Similarly, no process can
  2690.         masquerade as another without the collusion of the TCP.
  2691.  
  2692.         If the active/passive flag is set to passive, then this is a
  2693.         call to LISTEN for an incoming connection.  A passive open may
  2694.         have either a fully specified foreign socket to wait for a
  2695.         particular connection or an unspecified foreign socket to wait
  2696.         for any call.  A fully specified passive call can be made active
  2697.         by the subsequent execution of a SEND.
  2698.  
  2699.         A full-duplex transmission control block (TCB) is created and
  2700.         partially filled in with data from the OPEN command parameters.
  2701.         The TCB format is described in more detail in section 5.4.
  2702.  
  2703.         On an active OPEN command, the TCP will begin the procedure to
  2704.         synchronize (i.e., establish) the connection at once.
  2705.  
  2706.  
  2707. [Page 42]                                                               
  2708.  
  2709.  
  2710. August 1979                                                             
  2711.                                            Transmission Control Protocol
  2712.                                                 Functional Specification
  2713.  
  2714.  
  2715.  
  2716.         The buffer size, if present, indicates that the caller will
  2717.         always receive data from the connection in that size of buffers.
  2718.         This buffer size is a measure of the buffer between the user and
  2719.         the local TCP.  The buffer size between the two TCPs may be
  2720.         different.
  2721.  
  2722.         The timeout, if present, permits the caller to set up a timeout
  2723.         for all buffers transmitted on the connection.  If a buffer is
  2724.         not successfully delivered to the destination within the timeout
  2725.         period, the TCP will abort the connection.  The present global
  2726.         default is 30 seconds.  The buffer retransmission rate may vary;
  2727.         most likely, it will be related to the measured time for
  2728.         responses from the remote TCP.
  2729.  
  2730.         Depending on the TCP implementation, either a local connection
  2731.         name will be returned to the user by the TCP, or the user will
  2732.         specify this local connection name (in which case another
  2733.         parameter is needed in the call).  The local connection name can
  2734.         then be used as a short hand term for the connection defined by
  2735.         the <local socket, foreign socket> pair.
  2736.  
  2737.       Send
  2738.  
  2739.         Format:  SEND(local connection name, buffer address, byte count,
  2740.         EOL flag, URGENT flag [, timeout])
  2741.  
  2742.         This call causes the data contained in the indicated user buffer
  2743.         to be sent on the indicated connection.  If the connection has
  2744.         not been opened, the SEND is considered an error.  Some
  2745.         implementations may allow users to SEND first; in which case, an
  2746.         automatic OPEN would be done.  If the calling process is not
  2747.         authorized to use this connection, an error is returned.
  2748.  
  2749.         If the EOL flag is set, the data is the End Of a Letter, and the
  2750.         EOL bit will be set in the last TCP segment created from the
  2751.         buffer.  If the EOL flag is not set, subsequent SENDs will
  2752.         appear to be part of the same letter.
  2753.  
  2754.         If the URGENT flag is set, segments resulting from this call
  2755.         will have the urgent pointer set to indicate that some of the
  2756.         data associated with this call is urgent.  This facility, for
  2757.         example, can be used to simulate "break" signals from terminals
  2758.         or error or completion codes from I/O devices.  The semantics of
  2759.         this signal to the receiving process are unspecified.  The
  2760.         receiving TCP will signal the urgent condition to the receiving
  2761.         process as long as the urgent pointer indicates that data
  2762.         preceding the urgent pointer has not been consumed by the
  2763.         receiving process.  The purpose of urgent is to stimulate the
  2764.  
  2765.  
  2766.                                                                [Page 43]
  2767.  
  2768.  
  2769.                                                              August 1979
  2770. Transmission Control Protocol
  2771. Functional Specification
  2772.  
  2773.  
  2774.  
  2775.         receiver to accept some urgent data and to indicate to the
  2776.         receiver when all the currently known urgent data has been
  2777.         received.
  2778.  
  2779.         The number of times the sending user's TCP signals urgent will
  2780.         not necessarily be equal to the number of times the receiving
  2781.         user will be notified of the presence of urgent data.
  2782.  
  2783.         If no foreign socket was specified in the OPEN, but the
  2784.         connection is established (e.g., because a LISTENing connection
  2785.         has become specific due to a foreign segment arriving for the
  2786.         local socket), then the designated buffer is sent to the implied
  2787.         foreign socket.  In general, users who make use of OPEN with an
  2788.         unspecified foreign socket can make use of SEND without ever
  2789.         explicitly knowing the foreign socket address.
  2790.  
  2791.         However, if a SEND is attempted before the foreign socket
  2792.         becomes specified, an error will be returned.  Users can use the
  2793.         STATUS call to determine the status of the connection.  In some
  2794.         implementations the TCP may notify the user when an unspecified
  2795.         socket is bound.
  2796.  
  2797.         If a timeout is specified, then the current timeout for this
  2798.         connection is changed to the new one.
  2799.  
  2800.         In the simplest implementation, SEND would not return control to
  2801.         the sending process until either the transmission was complete
  2802.         or the timeout had been exceeded.  However, this simple method
  2803.         is both highly subject to deadlocks (for example, both sides of
  2804.         the connection might try to do SENDs before doing any RECEIVEs)
  2805.         and offers poor performance, so it is not recommended.  A more
  2806.         sophisticated implementation would return immediately to allow
  2807.         the process to run concurrently with network I/O, and,
  2808.         furthermore, to allow multiple SENDs to be in progress.
  2809.         Multiple SENDs are served in first come, first served order, so
  2810.         the TCP will queue those it cannot service immediately.
  2811.  
  2812.         We have implicitly assumed an asynchronous user interface in
  2813.         which a SEND later elicits some kind of SIGNAL or
  2814.         pseudo-interrupt from the serving TCP.  An alternative is to
  2815.         return a response immediately.  For instance, SENDs might return
  2816.         immediate local acknowledgment, even if the segment sent had not
  2817.         been acknowledged by the distant TCP.  We could optimistically
  2818.         assume eventual success.  If we are wrong, the connection will
  2819.         close anyway due to the timeout.  In implementations of this
  2820.         kind (synchronous), there will still be some asynchronous
  2821.         signals, but these will deal with the connection itself, and not
  2822.         with specific segments or letters.
  2823.  
  2824.  
  2825. [Page 44]                                                               
  2826.  
  2827.  
  2828. August 1979                                                             
  2829.                                            Transmission Control Protocol
  2830.                                                 Functional Specification
  2831.  
  2832.  
  2833.  
  2834.         NOTA BENE: In order for the process to distinguish among error
  2835.         or success indications for different SENDs, it might be
  2836.         appropriate for the buffer address to be returned along with the
  2837.         coded response to the SEND request.  We will offer an example
  2838.         event code format below, showing the information which should be
  2839.         returned to the calling process.
  2840.  
  2841.       Receive
  2842.  
  2843.         Format:  RECEIVE (local connection name, buffer address, byte
  2844.         count)
  2845.  
  2846.         This command allocates a receiving buffer associated with the
  2847.         specified connection.  If no OPEN precedes this command or the
  2848.         calling process is not authorized to use this connection, an
  2849.         error is returned.
  2850.  
  2851.         In the simplest implementation, control would not return to the
  2852.         calling program until either the buffer was filled, or some
  2853.         error occurred, but this scheme is highly subject to deadlocks.
  2854.         A more sophisticated implementation would permit several
  2855.         RECEIVEs to be outstanding at once.  These would be filled as
  2856.         letters, segments or fragments arrive.  This strategy permits
  2857.         increased throughput at the cost of a more elaborate scheme
  2858.         (possibly asynchronous) to notify the calling program that a
  2859.         letter has been received or a buffer filled.
  2860.  
  2861.         If insufficient buffer space is given to reassemble a complete
  2862.         letter, the EOL flag will not be set in the response to the
  2863.         RECEIVE.  The buffer will be filled with as much data as it can
  2864.         hold.  The last buffer required to hold the letter is returned
  2865.         with EOL signaled.
  2866.  
  2867.         The remaining parts of a partly delivered letter will be placed
  2868.         in buffers as they are made available via successive RECEIVEs.
  2869.         If a number of RECEIVEs are outstanding, they may be filled with
  2870.         parts of a single long letter or with at most one letter each.
  2871.         The event codes associated with each RECEIVE will indicate what
  2872.         is contained in the buffer.
  2873.  
  2874.         If a buffer size was given in the OPEN call, then all buffers
  2875.         presented in RECEIVE calls must be of exactly that size, or an
  2876.         error indication will be returned.
  2877.  
  2878.         The URGENT flag will be set only if the receiving user has
  2879.         previously been informed via a general event, that urgent data
  2880.         is waiting.  The receiving user should thus be in "read-fast"
  2881.         mode.  If the URGENT flag is on, additional urgent data remains.
  2882.  
  2883.  
  2884.                                                                [Page 45]
  2885.  
  2886.  
  2887.                                                              August 1979
  2888. Transmission Control Protocol
  2889. Functional Specification
  2890.  
  2891.  
  2892.  
  2893.         If the URGENT flag is off, this call to RECEIVE has returned all
  2894.         the urgent data, and the user may now leave "read-fast" mode.
  2895.  
  2896.         To distinguish among several outstanding RECEIVEs and to take
  2897.         care of the case that a letter is smaller than the buffer
  2898.         supplied, the event code is accompanied by both a buffer pointer
  2899.         and a byte count indicating the actual length of the letter
  2900.         received.
  2901.  
  2902.         Alternative implementations of RECEIVE might have the TCP
  2903.         allocate buffer storage, or the TCP might share a ring buffer
  2904.         with the user.  Variations of this kind will produce obvious
  2905.         variation in user interface to the TCP.
  2906.  
  2907.       Close
  2908.  
  2909.         Format:  CLOSE(local connection name)
  2910.  
  2911.         This command causes the connection specified to be closed.  If
  2912.         the connection is not open or the calling process is not
  2913.         authorized to use this connection, an error is returned.
  2914.         Closing connections is intended to be a graceful operation in
  2915.         the sense that outstanding SENDs will be transmitted (and
  2916.         retransmitted), as flow control permits, until all have been
  2917.         serviced.  Thus, it should be acceptable to make several SEND
  2918.         calls, followed by a CLOSE, and expect all the data to be sent
  2919.         to the destination.  It should also be clear that users should
  2920.         continue to RECEIVE on CLOSING connections, since the other side
  2921.         may be trying to transmit the last of its data.  Thus, CLOSE
  2922.         means "I have no more to send" but does not mean "I will not
  2923.         receive any more."  It may happen (if the user level protocol is
  2924.         not well thought out) that the closing side is unable to get rid
  2925.         of all its data before timing out.  In this event, CLOSE turns
  2926.         into ABORT, and the closing TCP gives up.
  2927.  
  2928.         The user may CLOSE the connection at any time on his own
  2929.         initiative, or in response to various prompts from the TCP
  2930.         (e.g., remote close executed, transmission timeout exceeded,
  2931.         destination inaccessible).
  2932.  
  2933.         Because closing a connection requires communication with the
  2934.         foreign TCP, connections may remain in the closing state for a
  2935.         short time.  Attempts to reopen the connection before the TCP
  2936.         replies to the CLOSE command will result in error responses.
  2937.  
  2938.         Close also implies end of letter.
  2939.  
  2940.  
  2941.  
  2942.  
  2943. [Page 46]                                                               
  2944.  
  2945.  
  2946. August 1979                                                             
  2947.                                            Transmission Control Protocol
  2948.                                                 Functional Specification
  2949.  
  2950.  
  2951.  
  2952.       Status
  2953.  
  2954.         Format:  STATUS(local connection name)
  2955.  
  2956.         This is an implementation dependent user command and could be
  2957.         excluded without adverse effect.  Information returned would
  2958.         typically come from the TCB associated with the connection.
  2959.  
  2960.         This command returns a data block containing the following
  2961.         information:
  2962.  
  2963.           local socket,
  2964.           foreign socket,
  2965.           local connection name,
  2966.           receive window,
  2967.           send window,
  2968.           connection state,
  2969.           number of buffers awaiting acknowledgment,
  2970.           number of buffers pending receipt (including partial ones),
  2971.           receive buffer size,
  2972.           urgent state,
  2973.           and default transmission timeout.
  2974.  
  2975.         Depending on the state of the connection, or on the
  2976.         implementation itself, some of this information may not be
  2977.         available or meaningful.  If the calling process is not
  2978.         authorized to use this connection, an error is returned.  This
  2979.         prevents unauthorized processes from gaining information about a
  2980.         connection.
  2981.  
  2982.       Abort
  2983.  
  2984.         Format:  ABORT (local connection name)
  2985.  
  2986.         This command causes all pending SENDs and RECEIVES to be
  2987.         aborted, the TCB to be removed, and a special RESET message to
  2988.         be sent to the TCP on the other side of the connection.
  2989.         Depending on the implementation, users may receive abort
  2990.         indications for each outstanding SEND or RECEIVE, or may simply
  2991.         receive an ABORT-acknowledgment.
  2992.  
  2993.  
  2994.  
  2995.  
  2996.  
  2997.  
  2998.  
  2999.  
  3000.  
  3001.  
  3002.                                                                [Page 47]
  3003.  
  3004.  
  3005.                                                              August 1979
  3006. Transmission Control Protocol
  3007. Functional Specification
  3008.  
  3009.  
  3010.  
  3011.     TCP-to-User Messages
  3012.  
  3013.       It is assumed that the operating system environment provides a
  3014.       means for the TCP to asynchronously signal the user program.  When
  3015.       the TCP does signal a user program, certain information is passed
  3016.       to the user.  Often in the specification the information will be
  3017.       an error message.  In other cases there will be information
  3018.       relating to the completion of processing a SEND or RECEIVE or
  3019.       other user call.
  3020.  
  3021.       The following information is provided:
  3022.  
  3023.         Local Connection Name                    Always
  3024.         Response String                          Always
  3025.         Buffer Address                           Send & Receive
  3026.         Byte count (counts bytes received)       Receive
  3027.         End-of-Letter flag                       Receive
  3028.         End-of-Urgent flag                       Receive
  3029.  
  3030.   TCP/Network Interface
  3031.  
  3032.     The TCP calls on a lower level protocol module to actually send and
  3033.     receive information over a network.  One case is that of the ARPA
  3034.     internetwork system where the lower level module is the Internet
  3035.     Protocol [1].  In most cases the following simple interface would be
  3036.     adequate.
  3037.  
  3038.     The following two calls satisfy the requirements for the TCP to
  3039.     internet protocol module communication:
  3040.  
  3041.       SEND (dest, TOS, TTL, BufPTR, len, Id, DF, options => result)
  3042.  
  3043.         where:
  3044.  
  3045.           dest = destination address
  3046.           TOS = type of service
  3047.           TTL = time to live
  3048.           BufPTR = buffer pointer
  3049.           len = length of buffer
  3050.           Id  = Identifier
  3051.           DF = Don't Fragment
  3052.           options = option data
  3053.           result = response
  3054.             OK = datagram sent ok
  3055.             Error = error in arguments or local network error
  3056.  
  3057.  
  3058.  
  3059.  
  3060.  
  3061. [Page 48]                                                               
  3062.  
  3063.  
  3064. August 1979                                                             
  3065.                                            Transmission Control Protocol
  3066.                                                 Functional Specification
  3067.  
  3068.  
  3069.  
  3070.       RECV (BufPTR => result, source, dest, prot, TOS, len)
  3071.  
  3072.         where:
  3073.  
  3074.           BufPTR = buffer pointer
  3075.           result = response
  3076.             OK = datagram received ok
  3077.             Error = error in arguments
  3078.           source = source address
  3079.           dest = destination address
  3080.           prot = protocol
  3081.           TOS = type of service
  3082.           len = length of buffer
  3083.  
  3084.       When the TCP sends a segment, it executes the SEND call supplying
  3085.       all the arguments.  The internet protocol module, on receiving
  3086.       this call, checks the arguments and prepares and sends the
  3087.       message.  If the arguments are good and the segment is accepted by
  3088.       the local network, the call returns successfully.  If either the
  3089.       arguments are bad, or the segment is not accepted by the local
  3090.       network, the call returns unsuccessfully.  On unsuccessful
  3091.       returns, a reasonable report should be made as to the cause of the
  3092.       problem, but the details of such reports are up to individual
  3093.       implementations.
  3094.  
  3095.       When a segment arrives at the internet protocol module from the
  3096.       local network, either there is a pending RECV call from TCP or
  3097.       there is not.  In the first case, the pending call is satisfied by
  3098.       passing the information from the segment to the TCP.  In the
  3099.       second case, the TCP is notified of a pending segment.
  3100.  
  3101.       The notification of a TCP may be via a pseudo interrupt or similar
  3102.       mechanism, as appropriate in the particular operating system
  3103.       environment of the implementation.
  3104.  
  3105.       A TCP's RECV call may then either be immediately satisfied by a
  3106.       pending segment, or the call may be pending until a segment
  3107.       arrives.
  3108.  
  3109.       We note that the Internet Protocol provides arguments for a type
  3110.       of service and for a time to live.  TCP uses the following
  3111.       settings for these parameters:
  3112.  
  3113.         type of service = Priority:  none, Package:  stream,
  3114.         Reliability:  higher, Preference:  speed, Speed:  higher; or
  3115.         00110110.
  3116.  
  3117.         time to live    = one minute, or 00111100.
  3118.  
  3119.  
  3120.                                                                [Page 49]
  3121.  
  3122.  
  3123.                                                              August 1979
  3124. Transmission Control Protocol
  3125. Functional Specification
  3126.  
  3127.  
  3128.  
  3129.           Note that the assumed maximum segment lifetime is two minutes.
  3130.           Here we explicitly ask that a segment be destroyed if it
  3131.           cannot be delivered by the internet system within one minute.
  3132.  
  3133. 3.8.  Event Processing
  3134.  
  3135.   The activity of the TCP can be characterized as responding to events.
  3136.   The events that occur can be cast into three categories:  user calls,
  3137.   arriving segments, and timeouts.  This section describes the
  3138.   processing the TCP does in response to each of the events.  In many
  3139.   cases the processing required depends on the state of the connection.
  3140.  
  3141.     Events that occur:
  3142.  
  3143.       User Calls
  3144.  
  3145.         OPEN
  3146.         SEND
  3147.         RECEIVE
  3148.         CLOSE
  3149.         ABORT
  3150.         STATUS
  3151.  
  3152.       Arriving Segments
  3153.  
  3154.         SEGMENT ARRIVES
  3155.  
  3156.       Timeouts
  3157.  
  3158.         USER TIMEOUT
  3159.         RETRANSMISSION TIMEOUT
  3160.  
  3161.   The model of the TCP/user interface is that user commands receive an
  3162.   immediate return and possibly a delayed response via an event or
  3163.   pseudo interrupt.  In the following descriptions, the term "signal"
  3164.   means cause a delayed response.
  3165.  
  3166.   Error responses are given as character strings.  For example, user
  3167.   commands referencing connections that do not exist receive "error:
  3168.   connection not open".
  3169.  
  3170.   Please note in the following that all arithmetic on sequence numbers,
  3171.   acknowledgment numbers, windows, et cetera, is modulo 2**32 the size
  3172.   of the sequence number space.  Also note that "=<" means less than or
  3173.   equal to.
  3174.  
  3175.   A natural way to think about processing incoming segments is to
  3176.   imagine that they are first tested for proper sequence number (i.e.,
  3177.  
  3178.  
  3179. [Page 50]                                                               
  3180.  
  3181.  
  3182. August 1979                                                             
  3183.                                            Transmission Control Protocol
  3184.                                                 Functional Specification
  3185.  
  3186.  
  3187.  
  3188.   that their contents lie in the range of the expected "receive window"
  3189.   in the sequence number space) and then that they are generally queued
  3190.   and processed in sequence number order.
  3191.  
  3192.   When a segment overlaps other already received segments we reconstruct
  3193.   the segment to contain just the new data, and adjust the header fields
  3194.   to be consistent.
  3195.  
  3196.  
  3197.  
  3198.  
  3199.  
  3200.  
  3201.  
  3202.  
  3203.  
  3204.  
  3205.  
  3206.  
  3207.  
  3208.  
  3209.  
  3210.  
  3211.  
  3212.  
  3213.  
  3214.  
  3215.  
  3216.  
  3217.  
  3218.  
  3219.  
  3220.  
  3221.  
  3222.  
  3223.  
  3224.  
  3225.  
  3226.  
  3227.  
  3228.  
  3229.  
  3230.  
  3231.  
  3232.  
  3233.  
  3234.  
  3235.  
  3236.  
  3237.  
  3238.                                                                [Page 51]
  3239.  
  3240.  
  3241.                                                              August 1979
  3242. Transmission Control Protocol
  3243. Functional Specification
  3244.                                                                OPEN Call
  3245.  
  3246.  
  3247.  
  3248.   OPEN Call
  3249.  
  3250.     CLOSED STATE (i.e., TCB does not exist)
  3251.  
  3252.       Create a new transmission control block (TCB) to hold connection
  3253.       state information.  Fill in local socket identifier, foreign
  3254.       socket, and user timeout information.  If active and the foreign
  3255.       socket is unspecified, return "error:  foreign socket
  3256.       unspecified"; if active and the foreign socket is specified, issue
  3257.       a SYN segment.  An initial send sequence number (ISS) is selected
  3258.       and a SYN segment of the form <SEQ=ISS><CTL=SYN> is sent.  Set
  3259.       SND.UNA to ISS, SND.NXT to ISS+1, SND.LBB to ISS+1, enter SYN-SENT
  3260.       state, and return.
  3261.  
  3262.       If the caller does not have access to the local socket specified,
  3263.       return "error:  connection illegal for this process".  If there is
  3264.       no room to create a new connection, return "error:  insufficient
  3265.       resources".
  3266.  
  3267.     LISTEN STATE
  3268.     SYN-SENT STATE
  3269.     SYN-RECEIVED STATE
  3270.     ESTABLISHED STATE
  3271.     FIN-WAIT-1 STATE
  3272.     FIN-WAIT-2 STATE
  3273.     TIME-WAIT STATE
  3274.     CLOSE-WAIT STATE
  3275.     CLOSING STATE
  3276.  
  3277.       Return "error:  connection already exists".
  3278.  
  3279.  
  3280.  
  3281.  
  3282.  
  3283.  
  3284.  
  3285.  
  3286.  
  3287.  
  3288.  
  3289.  
  3290.  
  3291.  
  3292.  
  3293.  
  3294.  
  3295.  
  3296.  
  3297. [Page 52]                                                               
  3298.  
  3299.  
  3300. August 1979                                                             
  3301.                                            Transmission Control Protocol
  3302.                                                 Functional Specification
  3303. SEND Call
  3304.  
  3305.  
  3306.  
  3307.   SEND Call
  3308.  
  3309.     CLOSED STATE (i.e., TCB does not exist)
  3310.  
  3311.       If the user should no have access to such a connection, then
  3312.       return "error:  connection illegal for this process".
  3313.  
  3314.       Otherwise, return "error:  connection does not exist".
  3315.  
  3316.     LISTEN STATE
  3317.  
  3318.       If the foreign socket is specified, then change the connection
  3319.       from passive to active, select an ISS, send a SYN segment, set
  3320.       SND.UNA to ISS, SND.NXT to ISS+1 and SND.LBB to ISS+1.  Enter
  3321.       SYN-SENT state.  Data associated with SEND may be sent with SYN
  3322.       segment or queued for transmission after entering ESTABLISHED
  3323.       state.  The urgent bit if requested in the command should be sent
  3324.       with the first data segment sent as a result of this command.  If
  3325.       there is no room to queue the request, respond with "error:
  3326.       insufficient resources".  If Foreign socket was not specified,
  3327.       then return "error:  foreign socket unspecified".
  3328.  
  3329.     SYN-SENT STATE
  3330.  
  3331.       Queue for processing after the connection is ESTABLISHED.
  3332.       Typically, nothing can be sent yet, anyway, because the send
  3333.       window has not yet been set by the other side.  If no space,
  3334.       return "error:  insufficient resources".
  3335.  
  3336.     SYN-RECEIVED STATE
  3337.  
  3338.       Queue for later processing after entering ESTABLISHED state.  If
  3339.       no space to queue, respond with "error:  insufficient resources".
  3340.  
  3341.     ESTABLISHED STATE
  3342.  
  3343.       Segmentize the buffer, send or queue it for output, with a
  3344.       piggybacked acknowledgment (acknowledgment value = SND.UNA) with
  3345.       the data (this is not required, but there is no advantage in not
  3346.       doing so).  If there is insufficient space to remember this
  3347.       buffer, simply return "error:  insufficient resources".
  3348.  
  3349.       If remote buffer size is not one octet, then, if this is the end
  3350.       of a letter, do the following end-of-letter/buffer-size adjustment
  3351.       processing:
  3352.  
  3353.  
  3354.  
  3355.  
  3356.                                                                [Page 53]
  3357.  
  3358.  
  3359.                                                              August 1979
  3360. Transmission Control Protocol
  3361. Functional Specification
  3362.                                                                SEND Call
  3363.  
  3364.  
  3365.  
  3366.         if EOL = 0 then
  3367.  
  3368.           SND.NXT <- SEG.SEQ + SEG.LEN
  3369.  
  3370.         if EOL = 1 then
  3371.  
  3372.           While SND.LBB < SEG.SEQ + SEG.LEN
  3373.           Do SND.LBB <- SND.LBB + SND.BS End
  3374.           SND.NXT <- SND.LBB
  3375.  
  3376.       If the urgent flag is set, then SND.UP <- SND.NXT-1 and set the
  3377.       urgent pointer in the outgoing segment.
  3378.  
  3379.     FIN-WAIT-1 STATE
  3380.     FIN-WAIT-2 STATE
  3381.     TIME-WAIT STATE
  3382.  
  3383.       Return "error:  connection closing" and do not service request.
  3384.  
  3385.     CLOSE-WAIT STATE
  3386.  
  3387.       Segmentize any text to be sent and queue for output.  If there is
  3388.       insufficient space to remember the SEND, return "error:
  3389.       insufficient resources"
  3390.  
  3391.     CLOSING STATE
  3392.  
  3393.       Respond with "error:  connection closing"
  3394.  
  3395.  
  3396.  
  3397.  
  3398.  
  3399.  
  3400.  
  3401.  
  3402.  
  3403.  
  3404.  
  3405.  
  3406.  
  3407.  
  3408.  
  3409.  
  3410.  
  3411.  
  3412.  
  3413.  
  3414.  
  3415. [Page 54]                                                               
  3416.  
  3417.  
  3418. August 1979                                                             
  3419.                                            Transmission Control Protocol
  3420.                                                 Functional Specification
  3421. RECEIVE Call
  3422.  
  3423.  
  3424.  
  3425.   RECEIVE Call
  3426.  
  3427.     CLOSED STATE (i.e., TCB does not exist)
  3428.  
  3429.       If the user should no have access to such a connection, return
  3430.       "error:  connection illegal for this process".
  3431.  
  3432.       Otherwise return "error:  connection does not exist".
  3433.  
  3434.     LISTEN STATE
  3435.     SYN-SENT STATE
  3436.     SYN-RECEIVED STATE
  3437.  
  3438.       Queue for processing after entering ESTABLISHED state.  If there
  3439.       is no room to queue this request, respond with "error:
  3440.       insufficient resources".
  3441.  
  3442.     ESTABLISHED STATE
  3443.  
  3444.       If insufficient incoming segments are queued to satisfy the
  3445.       request, queue the request.  If there is no queue space to
  3446.       remember the RECEIVE, respond with "error:  insufficient
  3447.       resources".
  3448.  
  3449.       Reassemble queued incoming segments into receive buffer and return
  3450.       to user.  Mark "end of letter" (EOL) if this is the case.
  3451.  
  3452.       If RCV.UP is in advance of the data currently being passed to the
  3453.       user notify the user of the presence of urgent data.
  3454.  
  3455.       When the TCP takes responsibility for delivering data to the user
  3456.       that fact must be communicated to the sender via an
  3457.       acknowledgment.  The formation of such an acknowledgment is
  3458.       described below in the discussion of processing an incoming
  3459.       segment.
  3460.  
  3461.     FIN-WAIT-1 STATE
  3462.     FIN-WAIT-2 STATE
  3463.  
  3464.       Reassemble and return a letter, or as much as will fit, in the
  3465.       user buffer.  Queue the request if it cannot be serviced
  3466.       immediately.
  3467.  
  3468.  
  3469.  
  3470.  
  3471.  
  3472.  
  3473.  
  3474.                                                                [Page 55]
  3475.  
  3476.  
  3477.                                                              August 1979
  3478. Transmission Control Protocol
  3479. Functional Specification
  3480.                                                             RECEIVE Call
  3481.  
  3482.  
  3483.  
  3484.     TIME-WAIT STATE
  3485.     CLOSE-WAIT STATE
  3486.  
  3487.       Since the remote side has already sent FIN, RECEIVEs must be
  3488.       satisfied by text already reassembled, but not yet delivered to
  3489.       the user.  If no reassembled segment text is awaiting delivery,
  3490.       the RECEIVE should get a "error:  connection closing" response.
  3491.       Otherwise, any remaining text can be used to satisfy the RECEIVE.
  3492.  
  3493.     CLOSING STATE
  3494.  
  3495.       Return "error:  connection closing"
  3496.  
  3497.  
  3498.  
  3499.  
  3500.  
  3501.  
  3502.  
  3503.  
  3504.  
  3505.  
  3506.  
  3507.  
  3508.  
  3509.  
  3510.  
  3511.  
  3512.  
  3513.  
  3514.  
  3515.  
  3516.  
  3517.  
  3518.  
  3519.  
  3520.  
  3521.  
  3522.  
  3523.  
  3524.  
  3525.  
  3526.  
  3527.  
  3528.  
  3529.  
  3530.  
  3531.  
  3532.  
  3533. [Page 56]                                                               
  3534.  
  3535.  
  3536. August 1979                                                             
  3537.                                            Transmission Control Protocol
  3538.                                                 Functional Specification
  3539. CLOSE Call
  3540.  
  3541.  
  3542.  
  3543.   CLOSE Call
  3544.  
  3545.     CLOSED STATE (i.e., TCB does not exist)
  3546.  
  3547.       If the user should no have access to such a connection, return
  3548.       "error:  connection illegal for this process".
  3549.  
  3550.       Otherwise, return "error:  connection does not exist".
  3551.  
  3552.     LISTEN STATE
  3553.  
  3554.       Any outstanding RECEIVEs should be returned with "error:  closing"
  3555.       responses.  Delete TCB, return "ok".
  3556.  
  3557.     SYN-SENT STATE
  3558.  
  3559.       Delete the TCB and return "error:  closing" responses to any
  3560.       queued SENDs, or RECEIVEs.
  3561.  
  3562.     SYN-RECEIVED STATE
  3563.  
  3564.       Queue for processing after entering ESTABLISHED state or
  3565.       segmentize and send FIN segment.  If the latter, enter FIN-WAIT-1
  3566.       state.
  3567.  
  3568.     ESTABLISHED STATE
  3569.  
  3570.       Queue this until all preceding SENDs have been segmentized, then
  3571.       form a FIN segment and send it.  In any case, enter FIN-WAIT-1
  3572.       state.
  3573.  
  3574.     FIN-WAIT-1 STATE
  3575.     FIN-WAIT-2 STATE
  3576.  
  3577.       Strictly speaking, this is an error and should receive a "error:
  3578.       connection closing" response.  An "ok" response would be
  3579.       acceptable, too, as long as a second FIN is not emitted (the first
  3580.       FIN may be retransmitted though).
  3581.  
  3582.  
  3583.  
  3584.  
  3585.  
  3586.  
  3587.  
  3588.  
  3589.  
  3590.  
  3591.  
  3592.                                                                [Page 57]
  3593.  
  3594.  
  3595.                                                              August 1979
  3596. Transmission Control Protocol
  3597. Functional Specification
  3598.                                                               CLOSE Call
  3599.  
  3600.  
  3601.  
  3602.     TIME-WAIT STATE
  3603.  
  3604.       Strictly speaking, this is an error and should receive a "error:
  3605.       connection closing" response.  An "ok" response would be
  3606.       acceptable, too.  However, since the FIN has been sent and
  3607.       acknowledged, nothing should be sent (or retransmitted).
  3608.  
  3609.     CLOSE-WAIT STATE
  3610.  
  3611.       Queue this request until all preceding SENDs have been
  3612.       segmentized; then send a FIN segment, enter CLOSING state.
  3613.  
  3614.     CLOSING STATE
  3615.  
  3616.       Respond with "error:  connection closing"
  3617.  
  3618.  
  3619.  
  3620.  
  3621.  
  3622.  
  3623.  
  3624.  
  3625.  
  3626.  
  3627.  
  3628.  
  3629.  
  3630.  
  3631.  
  3632.  
  3633.  
  3634.  
  3635.  
  3636.  
  3637.  
  3638.  
  3639.  
  3640.  
  3641.  
  3642.  
  3643.  
  3644.  
  3645.  
  3646.  
  3647.  
  3648.  
  3649.  
  3650.  
  3651. [Page 58]                                                               
  3652.  
  3653.  
  3654. August 1979                                                             
  3655.                                            Transmission Control Protocol
  3656.                                                 Functional Specification
  3657. ABORT Call
  3658.  
  3659.  
  3660.  
  3661.   ABORT Call
  3662.  
  3663.     CLOSED STATE (i.e., TCB does not exist)
  3664.  
  3665.       If the user should no have access to such a connection, return
  3666.       "error:  connection illegal for this process".
  3667.  
  3668.       Otherwise return "error:  connection does not exist".
  3669.  
  3670.     LISTEN STATE
  3671.  
  3672.       Any outstanding RECEIVEs should be returned with "error:
  3673.       connection reset" responses.  Delete TCB, return "ok".
  3674.  
  3675.     SYN-SENT STATE
  3676.  
  3677.       Delete the TCB and return "reset" responses to any queued SENDs,
  3678.       or RECEIVEs.
  3679.  
  3680.     SYN-RECEIVED STATE
  3681.  
  3682.       Send a RST of the form:
  3683.  
  3684.         <SEQ=SND.NXT><ACK=RCV.NXT><CTL=RST,ACK>
  3685.  
  3686.       and return any unprocessed SENDs, or RECEIVEs with "reset" code,
  3687.       delete the TCB.
  3688.  
  3689.     ESTABLISHED STATE
  3690.  
  3691.       Send a reset segment:
  3692.  
  3693.         <SEQ=SND.NXT><ACK=RCV.NXT><CTL=RST,ACK>
  3694.  
  3695.       All queued SENDs and RECEIVEs should be given "reset" responses;
  3696.       all segments queued for transmission (except for the RST formed
  3697.       above) or retransmission should be flushed, delete the TCB.
  3698.  
  3699.  
  3700.  
  3701.  
  3702.  
  3703.  
  3704.  
  3705.  
  3706.  
  3707.  
  3708.  
  3709.  
  3710.                                                                [Page 59]
  3711.  
  3712.  
  3713.                                                              August 1979
  3714. Transmission Control Protocol
  3715. Functional Specification
  3716.                                                               ABORT Call
  3717.  
  3718.  
  3719.  
  3720.     FIN-WAIT-1 STATE
  3721.     FIN-WAIT-2 STATE
  3722.  
  3723.       A reset segment (RST) should be formed and sent:
  3724.  
  3725.         <SEQ=SND.NXT><ACK=RCV.NXT><CTL=RST,ACK>
  3726.  
  3727.       Outstanding SENDs, RECEIVEs, CLOSEs, and/or segments queued for
  3728.       retransmission, or segmentizing, should be flushed, with
  3729.       "connection reset" notification to the user, delete the TCB.
  3730.  
  3731.     TIME-WAIT STATE
  3732.  
  3733.       Respond with "ok" and delete the TCB.
  3734.  
  3735.     CLOSE-WAIT STATE
  3736.  
  3737.       Flush any pending SENDs and RECEIVEs, returning "connection reset"
  3738.       responses for them.  Form and send a RST segment:
  3739.  
  3740.         <SEQ=SND.NXT><ACK=RCV.NXT><CTL=RST,ACK>
  3741.  
  3742.       Flush all segment queues and delete the TCB.
  3743.  
  3744.     CLOSING STATE
  3745.  
  3746.       Respond with "ok" and delete the TCB; flush any remaining segment
  3747.       queues.  If a CLOSE command is still pending, respond "error:
  3748.       connection reset".
  3749.  
  3750.  
  3751.  
  3752.  
  3753.  
  3754.  
  3755.  
  3756.  
  3757.  
  3758.  
  3759.  
  3760.  
  3761.  
  3762.  
  3763.  
  3764.  
  3765.  
  3766.  
  3767.  
  3768.  
  3769. [Page 60]                                                               
  3770.  
  3771.  
  3772. August 1979                                                             
  3773.                                            Transmission Control Protocol
  3774.                                                 Functional Specification
  3775. STATUS Call
  3776.  
  3777.  
  3778.  
  3779.   STATUS Call
  3780.  
  3781.     CLOSED STATE (i.e., TCB does not exist)
  3782.  
  3783.       If the user should no have access to such a connection, return
  3784.       "error:  connection illegal for this process".
  3785.  
  3786.       Otherwise return "error:  connection does not exist".
  3787.  
  3788.     LISTEN STATE
  3789.  
  3790.       Return "state = LISTEN", and the TCB pointer.
  3791.  
  3792.     SYN-SENT STATE
  3793.  
  3794.       Return "state = SYN-SENT", and the TCB pointer.
  3795.  
  3796.     SYN-RECEIVED STATE
  3797.  
  3798.       Return "state = SYN-RECEIVED", and the TCB pointer.
  3799.  
  3800.     ESTABLISHED STATE
  3801.  
  3802.       Return "state = ESTABLISHED", and the TCB pointer.
  3803.  
  3804.     FIN-WAIT-1 STATE
  3805.  
  3806.       Return "state = FIN-WAIT-1", and the TCB pointer.
  3807.  
  3808.     FIN-WAIT-2 STATE
  3809.  
  3810.       Return "state = FIN-WAIT-2", and the TCB pointer.
  3811.  
  3812.     TIME-WAIT STATE
  3813.  
  3814.       Return "state = TIME-WAIT and the TCB pointer.
  3815.  
  3816.     CLOSE-WAIT STATE
  3817.  
  3818.       Return "state = CLOSE-WAIT", and the TCB pointer.
  3819.  
  3820.     CLOSING STATE
  3821.  
  3822.       Return "state = CLOSING", and the TCB pointer.
  3823.  
  3824.  
  3825.  
  3826.  
  3827.  
  3828.                                                                [Page 61]
  3829.  
  3830.  
  3831.                                                              August 1979
  3832. Transmission Control Protocol
  3833. Functional Specification
  3834.                                                          SEGMENT ARRIVES
  3835.  
  3836.  
  3837.  
  3838.   SEGMENT ARRIVES
  3839.  
  3840.     If the state is CLOSED (i.e., TCB does not exist) then
  3841.  
  3842.       all data in the incoming segment is discarded.  An incoming
  3843.       segment containing a RST is discarded.  An incoming segment not
  3844.       containing a RST causes a RST to be sent in response.  The
  3845.       acknowledgment and sequence field values are selected to make the
  3846.       reset sequence acceptable to the TCP that sent the offending
  3847.       segment.
  3848.  
  3849.       If the ACK bit is off, sequence number zero is used,
  3850.  
  3851.         <SEQ=0><ACK=SEG.SEQ+SEG.LEN><CTL=RST,ACK>
  3852.  
  3853.       If the ACK bit is on,
  3854.  
  3855.         <SEQ=SEG.ACK><CTL=RST>
  3856.  
  3857.       Return.
  3858.  
  3859.     If the state is LISTEN then
  3860.  
  3861.       first check for an ACK
  3862.  
  3863.         Any acknowledgment is bad if it arrives on a connection still in
  3864.         the LISTEN state.  An acceptable reset segment should be formed
  3865.         for any arriving ACK-bearing segment, except another RST.  The
  3866.         RST should be formatted as follows:
  3867.  
  3868.           <SEQ=SEG.ACK><CTL=RST>
  3869.  
  3870.         Return.
  3871.  
  3872.         An incoming RST should be ignored.  Return.
  3873.  
  3874.       if there was no ACK then check for a SYN
  3875.  
  3876.         If the SYN bit is set, RCV.NXT and RCV.LBB are set to SEG.SEQ+1,
  3877.         IRS is set to SEG.SEQ and any other control or text should be
  3878.         queued for processing later.  ISS should be selected and a SYN
  3879.         segment sent of the form:
  3880.  
  3881.           <SEQ=ISS><ACK=RCV.NXT><CTL=SYN,ACK>
  3882.  
  3883.         SND.NXT and SND.LBB are set to ISS+1 and SND.UNA to ISS.  The
  3884.         connection state should be changed to SYN-RECEIVED.  Note that
  3885.  
  3886.  
  3887. [Page 62]                                                               
  3888.  
  3889.  
  3890. August 1979                                                             
  3891.                                            Transmission Control Protocol
  3892.                                                 Functional Specification
  3893. SEGMENT ARRIVES
  3894.  
  3895.  
  3896.  
  3897.         any other incoming control or data (combined with SYN) will be
  3898.         processed in the SYN-RECEIVED state, but processing of SYN and
  3899.         ACK should not be repeated.
  3900.  
  3901.         This segment may also include data and control bits (e.g., URG,
  3902.         EOL) which were queued for transmission.
  3903.  
  3904.       if there was no SYN but there was other text or control
  3905.  
  3906.         Any other control or text-bearing segment (not containing SYN)
  3907.         should have an ACK and thus would be discarded by the ACK
  3908.         processing.  An incoming RST segment could not be valid, since
  3909.         it could not have been sent in response to anything sent by this
  3910.         incarnation of the connection.  So you are unlikely to get here,
  3911.         but if you do, drop the segment, and return.
  3912.  
  3913.     If the state is SYN-SENT then
  3914.  
  3915.       first check for an ACK
  3916.  
  3917.         If SND.UNA < SEG.ACK =< SND.NXT then the ACK is acceptable.
  3918.         SND.UNA should be advanced to equal SEG.ACK, and any segments on
  3919.         the retransmission queue which are thereby acknowledged should
  3920.         be removed.
  3921.  
  3922.         If the segment acknowledgment is not acceptable (a segment
  3923.         without an ACK is acceptable) and the RST bit is off, send an
  3924.         acceptable RST segment of the form:
  3925.  
  3926.           <SEQ=SEG.ACK><CTL=RST>
  3927.  
  3928.         and discard the segment.  Return.
  3929.  
  3930.       if the ACK is ok (or there is no ACK), check the RST bit
  3931.  
  3932.         If the RST bit is set then signal the user "error:  connection
  3933.         reset", enter CLOSED state, drop the segment, delete TCB, and
  3934.         return.
  3935.  
  3936.       if the ACK is ok (or there is no ACK) and it was not a RST, check
  3937.       the SYN bit
  3938.  
  3939.         If the SYN bit is on then, RCV.NXT and RCV.LBB are set to
  3940.         SEG.SEQ+1, IRS is set to SEG.SEQ.  If SND.UNA > ISS (our SYN has
  3941.         been ACKed), change the connection state to ESTABLISHED,
  3942.         otherwise enter SYN-RECEIVED.  In any case, form an ACK segment:
  3943.  
  3944.  
  3945.  
  3946.                                                                [Page 63]
  3947.  
  3948.  
  3949.                                                              August 1979
  3950. Transmission Control Protocol
  3951. Functional Specification
  3952.                                                          SEGMENT ARRIVES
  3953.  
  3954.  
  3955.  
  3956.           <SEQ=SND.NXT><ACK=RCV.NXT><CTL=ACK>
  3957.  
  3958.         and send it.  Data or controls which were queued for
  3959.         transmission may be included.
  3960.  
  3961.         If there are other controls or text in the segment then continue
  3962.         processing at the fifth step below where the URG bit is checked,
  3963.         otherwise return.
  3964.  
  3965.     Otherwise,
  3966.  
  3967.     first check sequence number
  3968.  
  3969.       SYN-RECEIVED STATE
  3970.       ESTABLISHED STATE
  3971.       FIN-WAIT-1 STATE
  3972.       FIN-WAIT-2 STATE
  3973.       TIME-WAIT STATE
  3974.       CLOSE-WAIT STATE
  3975.       CLOSING STATE
  3976.  
  3977.         Segments are processed in sequence.  Initial tests on arrival
  3978.         are used to discard old duplicates, but further processing is
  3979.         done in SEG.SEQ order.  If a segment's contents straddle the
  3980.         boundary between old and new, only the new parts should be
  3981.         processed.
  3982.  
  3983.         There are four cases for the acceptability test for an incoming
  3984.         segment:
  3985.  
  3986.         Segment Receive  Test
  3987.         Length  Window
  3988.         ------- -------  -------------------------------------------
  3989.  
  3990.            0       0     SEG.SEQ = RCV.NXT
  3991.  
  3992.            0      >0     RCV.NXT =< SEG.SEQ < RCV.NXT+RCV.WND
  3993.  
  3994.           >0       0     not acceptable
  3995.  
  3996.           >0      >0     RCV.NXT < SEG.SEQ+SEG.LEN =< RCV.NXT+RCV.WND
  3997.  
  3998.         Note that the test above guarantees that the last sequence
  3999.         number used by the segment lies in the receive-window.  If the
  4000.         RCV.WND is zero, no segments will be acceptable, but special
  4001.         allowance should be made to accept valid ACKs.
  4002.  
  4003.  
  4004.  
  4005. [Page 64]                                                               
  4006.  
  4007.  
  4008. August 1979                                                             
  4009.                                            Transmission Control Protocol
  4010.                                                 Functional Specification
  4011. SEGMENT ARRIVES
  4012.  
  4013.  
  4014.  
  4015.         If an incoming segment is not acceptable, an acknowledgment
  4016.         should be sent in reply:
  4017.  
  4018.           <SEQ=SND.NXT><ACK=RCV.NXT><CTL=ACK>
  4019.  
  4020.         If the incoming segment is unacceptable, drop it and return.
  4021.  
  4022.     second check the ACK field,
  4023.  
  4024.       SYN-RECEIVED STATE
  4025.  
  4026.         If the RST bit is off and SND.UNA < SEG.ACK =< SND.NXT then set
  4027.         SND.UNA <- SEG.ACK, remove any acknowledged segments from the
  4028.         retransmission queue, and enter ESTABLISHED state.
  4029.  
  4030.         If the segment acknowledgment is not acceptable, form a reset
  4031.         segment,
  4032.  
  4033.           <SEQ=SEG.ACK><CTL=RST>
  4034.  
  4035.         and send it, unless the incoming segment is an RST (or there is
  4036.         no ACK), in which case, it should be discarded, then return.
  4037.  
  4038.       ESTABLISHED STATE
  4039.  
  4040.         If SND.UNA < SEG.ACK =< SND.NXT then, set SND.UNA <- SEG.ACK.
  4041.         Any segments on the retransmission queue which are thereby
  4042.         entirely acknowledged are removed.  Users should receive
  4043.         positive acknowledgments for buffers which have been SENT and
  4044.         fully acknowledged (i.e., SEND buffer should be returned with
  4045.         "ok" response).  If the ACK is a duplicate, it can be ignored.
  4046.  
  4047.         If the segment passes the sequence number and acknowledgment
  4048.         number tests, the send window should be updated.  If
  4049.         SND.WL =< SEG.SEQ, set SND.WND <- SEG.WND and set
  4050.         SND.WL <- SEG.SEQ.
  4051.  
  4052.         If the remote buffer size is not one, then the
  4053.         end-of-letter/buffer-size adjustment to sequence numbers may
  4054.         have an effect on the next expected sequence number to be
  4055.         acknowledged.  It is possible that the remote TCP will
  4056.         acknowledge with a SEG.ACK equal to a sequence number of an
  4057.         octet that was skipped over at the end of a letter.  This a mild
  4058.         error on the remote TCPs part, but not cause for alarm.
  4059.  
  4060.  
  4061.  
  4062.  
  4063.  
  4064.                                                                [Page 65]
  4065.  
  4066.  
  4067.                                                              August 1979
  4068. Transmission Control Protocol
  4069. Functional Specification
  4070.                                                          SEGMENT ARRIVES
  4071.  
  4072.  
  4073.  
  4074.       FIN-WAIT-1 STATE
  4075.       FIN-WAIT-2 STATE
  4076.  
  4077.         In addition to the processing for the ESTABLISHED state, if the
  4078.         retransmission queue is empty, the user's CLOSE can be
  4079.         acknowledged ("ok") but do not delete the TCB.
  4080.  
  4081.       TIME-WAIT STATE
  4082.  
  4083.         The only thing that can arrive in this state is a retransmission
  4084.         of the remote FIN.  Acknowledge it, and restart the 2 MSL
  4085.         timeout.
  4086.  
  4087.       CLOSE-WAIT STATE
  4088.       CLOSING STATE
  4089.  
  4090.         Do the same processing as for the ESTABLISHED state.
  4091.  
  4092.     third, check the RST bit,
  4093.  
  4094.       SYN-RECEIVED STATE
  4095.  
  4096.         If the RST bit is set then, if the segment has passed sequence
  4097.         and acknowledgment tests, it is valid.  If this connection was
  4098.         initiated with a passive OPEN (i.e., came from the LISTEN
  4099.         state), then return this connection to LISTEN state.  The user
  4100.         need not be informed.  If this connection was initiated with an
  4101.         active OPEN (i.e., came from SYN-SENT state) then the connection
  4102.         was refused, signal the user "connection refused".  In either
  4103.         case, all segments on the retransmission queue should be
  4104.         removed.
  4105.  
  4106.       ESTABLISHED
  4107.       FIN-WAIT-1
  4108.       FIN-WAIT-2
  4109.       CLOSE-WAIT
  4110.       CLOSING STATE
  4111.  
  4112.         If the RST bit is set then, any outstanding RECEIVEs and SEND
  4113.         should receive "reset" responses.  All segment queues should be
  4114.         flushed.  Users should also receive an unsolicited general
  4115.         "connection reset" signal.  Enter the CLOSED state, delete the
  4116.         TCB, and return.
  4117.  
  4118.       TIME-WAIT
  4119.  
  4120.         Enter the CLOSED state, delete the TCB, and return.
  4121.  
  4122.  
  4123. [Page 66]                                                               
  4124.  
  4125.  
  4126. August 1979                                                             
  4127.                                            Transmission Control Protocol
  4128.                                                 Functional Specification
  4129. SEGMENT ARRIVES
  4130.  
  4131.  
  4132.  
  4133.     fourth, check the SYN bit,
  4134.  
  4135.       SYN-RECEIVED
  4136.       ESTABLISHED STATE
  4137.  
  4138.         If the SYN bit is set, check the segment sequence number against
  4139.         the receive window.  The segment sequence number must be in the
  4140.         receive window; if not, ignore the segment.  If the SYN is on
  4141.         and SEG.SEQ = RCV.NXT-1, then everything is ok and no action is
  4142.         needed; but if they are not equal, there is an error and a reset
  4143.         must be sent.
  4144.  
  4145.           If a reset must be sent it is formed as follows:
  4146.  
  4147.             <SEQ=SEG.ACK><CTL=RST>
  4148.  
  4149.           The connection must be aborted as if a RST had been received.
  4150.  
  4151.       FIN-WAIT STATE-1
  4152.       FIN-WAIT STATE-2
  4153.       TIME-WAIT STATE
  4154.       CLOSE-WAIT STATE
  4155.       CLOSING STATE
  4156.  
  4157.         This case should not occur, since a duplicate of the SYN which
  4158.         started the current connection incarnation will have been
  4159.         filtered in the SEG.SEQ processing.  Other SYN's will have been
  4160.         rejected by this test as well (see SYN processing for
  4161.         ESTABLISHED state).
  4162.  
  4163.     fifth, check the URG bit,
  4164.  
  4165.       ESTABLISHED STATE
  4166.       FIN-WAIT-1 STATE
  4167.       FIN-WAIT-2 STATE
  4168.  
  4169.         If the URG bit is set, RCV.UP <- max(RCV.UP,SEG.UP), and signal
  4170.         the user that the remote side has urgent data if the urgent
  4171.         pointer (RCV.UP) is in advance of the data consumed.  If the
  4172.         user has already been signaled (or is still in the "urgent
  4173.         mode") for this continuous sequence of urgent data, do not
  4174.         signal the user again.
  4175.  
  4176.  
  4177.  
  4178.  
  4179.  
  4180.  
  4181.  
  4182.                                                                [Page 67]
  4183.  
  4184.  
  4185.                                                              August 1979
  4186. Transmission Control Protocol
  4187. Functional Specification
  4188.                                                          SEGMENT ARRIVES
  4189.  
  4190.  
  4191.  
  4192.       TIME-WAIT STATE
  4193.       CLOSE-WAIT STATE
  4194.       CLOSING
  4195.  
  4196.         This should not occur, since a FIN has been received from the
  4197.         remote side.  Ignore the URG.
  4198.  
  4199.     sixth, process the segment text,
  4200.  
  4201.       ESTABLISHED STATE
  4202.  
  4203.         Once in the ESTABLISHED state, it is possible to deliver segment
  4204.         text to user RECEIVE buffers.  Text from segments can be moved
  4205.         into buffers until either the buffer is full or the segment is
  4206.         empty.  If the segment empties and carries an EOL flag, then the
  4207.         user is informed, when the buffer is returned, that an EOL has
  4208.         been received.
  4209.  
  4210.         If buffer size is not one octet, then do  the following
  4211.         end-of-letter/buffer-size adjustment processing:
  4212.  
  4213.           if EOL = 0 then
  4214.  
  4215.             RCV.NXT <- SEG.SEQ + SEG.LEN
  4216.  
  4217.           if EOL = 1 then
  4218.  
  4219.             While RCV.LBB < SEG.SEQ+SEG.LEN
  4220.             Do RCV.LBB <- RCV.LBB + RCV.BS End
  4221.             RCV.NXT <- RCV.LBB
  4222.  
  4223.         When the TCP takes responsibility for delivering the data to the
  4224.         user it must also acknowledge the receipt of the data.  Send an
  4225.         acknowledgment of the form:
  4226.  
  4227.           <SEQ=SND.NXT><ACK=RCV.NXT><CTL=ACK>
  4228.  
  4229.         This acknowledgment should be piggybacked on a segment being
  4230.         transmitted if possible without incurring undue delay.
  4231.  
  4232.  
  4233.  
  4234.  
  4235.  
  4236.  
  4237.  
  4238.  
  4239.  
  4240.  
  4241. [Page 68]                                                               
  4242.  
  4243.  
  4244. August 1979                                                             
  4245.                                            Transmission Control Protocol
  4246.                                                 Functional Specification
  4247. SEGMENT ARRIVES
  4248.  
  4249.  
  4250.  
  4251.       FIN-WAIT-1 STATE
  4252.       FIN-WAIT-2 STATE
  4253.  
  4254.         If there are outstanding RECEIVEs, they should be satisfied, if
  4255.         possible, with the text of this segment; remaining text should
  4256.         be queued for further processing.  If a RECEIVE is satisfied,
  4257.         the user should be notified, with "end-of-letter" (EOL) signal,
  4258.         if appropriate.
  4259.  
  4260.       TIME-WAIT STATE
  4261.       CLOSE-WAIT STATE
  4262.  
  4263.         This should not occur, since a FIN has been received from the
  4264.         remote side.  Ignore the segment text.
  4265.  
  4266.     seventh, check the FIN bit,
  4267.  
  4268.       Send an acknowledgment for the FIN.  Signal the user "connection
  4269.       closing", and return any pending RECEIVEs with same message.  Note
  4270.       that FIN implies EOL for any segment text not yet delivered to the
  4271.       user.  If the current state is ESTABLISHED, enter the CLOSE-WAIT
  4272.       state.  If the current state is FIN-WAIT-1, enter the CLOSING
  4273.       state.  If the current state is FIN-WAIT-2, enter the TIME-WAIT
  4274.       state.
  4275.  
  4276.     and return.
  4277.  
  4278.  
  4279.  
  4280.  
  4281.  
  4282.  
  4283.  
  4284.  
  4285.  
  4286.  
  4287.  
  4288.  
  4289.  
  4290.  
  4291.  
  4292.  
  4293.  
  4294.  
  4295.  
  4296.  
  4297.  
  4298.  
  4299.  
  4300.                                                                [Page 69]
  4301.  
  4302.  
  4303.                                                              August 1979
  4304. Transmission Control Protocol
  4305. Functional Specification
  4306.                                                             USER TIMEOUT
  4307.  
  4308.  
  4309.  
  4310.   USER TIMEOUT
  4311.  
  4312.     For any state if the user timeout expires, flush all queues, signal
  4313.     the user "error:  connection aborted due to user timeout" in general
  4314.     and for any outstanding calls, delete the TCB, and return.
  4315.  
  4316.   RETRANSMISSION TIMEOUT
  4317.  
  4318.     For any state if the retransmission timeout expires on a segment in
  4319.     the retransmission queue, send the segment at the front of the
  4320.     retransmission queue again, reinitialize the retransmission timer,
  4321.     and return.
  4322.  
  4323.    
  4324.  
  4325.  
  4326.  
  4327.  
  4328.  
  4329.  
  4330.  
  4331.  
  4332.  
  4333.  
  4334.  
  4335.  
  4336.  
  4337.  
  4338.  
  4339.  
  4340.  
  4341.  
  4342.  
  4343.  
  4344.  
  4345.  
  4346.  
  4347.  
  4348.  
  4349.  
  4350.  
  4351.  
  4352.  
  4353.  
  4354.  
  4355.  
  4356.  
  4357.  
  4358.  
  4359. [Page 70]                                                               
  4360.  
  4361.  
  4362. August 1979                                                             
  4363.                                            Transmission Control Protocol
  4364.  
  4365.  
  4366.  
  4367.                                 GLOSSARY
  4368.  
  4369.  
  4370.  
  4371. 1822
  4372.           BBN Report 1822, "The Specification of the Interconnection of
  4373.           a Host and an IMP".  The specification of interface between a
  4374.           host and the ARPANET.
  4375.  
  4376. ACK
  4377.           A control bit (acknowledge) occupying no sequence space, which
  4378.           indicates that the acknowledgment field of this segment
  4379.           specifies the next sequence number the sender of this segment
  4380.           is expecting to receive, hence acknowledging receipt of all
  4381.           previous sequence numbers.
  4382.  
  4383. ARPANET message
  4384.           The unit of transmission between a host and an IMP in the
  4385.           ARPANET.  The maximum size is about 1012 octets (8096 bits).
  4386.  
  4387. ARPANET packet
  4388.           A unit of transmission used internally in the ARPANET between
  4389.           IMPs.  The maximum size is about 126 octets (1008 bits).
  4390.  
  4391. buffer size
  4392.           An option (buffer size) used to state the receive data buffer
  4393.           size of the sender of this option.  May only be sent in a
  4394.           segment that also carries a SYN.
  4395.  
  4396. connection
  4397.           A logical communication path identified by a pair of sockets.
  4398.  
  4399. datagram
  4400.           A message sent in a packet switched computer communications
  4401.           network.
  4402.  
  4403. Destination Address
  4404.           The destination address, usually the network and host
  4405.           identifiers.
  4406.  
  4407. EOL
  4408.           A control bit (End of Letter) occupying no sequence space,
  4409.           indicating that this segment ends a logical letter with the
  4410.           last data octet in the segment.  If this end of letter causes
  4411.           a less than full buffer to be released to the user and the
  4412.           connection buffer size is not one octet then the
  4413.           end-of-letter/buffer-size adjustment to the receive sequence
  4414.           number must be made.
  4415.  
  4416.  
  4417.  
  4418.                                                                [Page 71]
  4419.  
  4420.  
  4421.                                                              August 1979
  4422. Transmission Control Protocol
  4423. Glossary
  4424.  
  4425.  
  4426.  
  4427. FIN
  4428.           A control bit (finis) occupying one sequence number, which
  4429.           indicates that the sender will send no more data or control
  4430.           occupying sequence space.
  4431.  
  4432. fragment
  4433.           A portion of a logical unit of data, in particular an internet
  4434.           fragment is a portion of an internet datagram.
  4435.  
  4436. FTP
  4437.           A file transfer protocol.
  4438.  
  4439. header
  4440.           Control information at the beginning of a message, segment,
  4441.           fragment, packet or block of data.
  4442.  
  4443. host
  4444.           A computer.  In particular a source or destination of messages
  4445.           from the point of view of the communication network.
  4446.  
  4447. Identification
  4448.           An Internet Protocol field.  This identifying value assigned
  4449.           by the sender aids in assembling the fragments of a datagram.
  4450.  
  4451. IMP
  4452.           The Interface Message Processor, the packet switch of the
  4453.           ARPANET.
  4454.  
  4455. internet address
  4456.           A source or destination address specific to the host level.
  4457.  
  4458. internet datagram
  4459.           The unit of data exchanged between an internet module and the
  4460.           higher level protocol together with the internet header.
  4461.  
  4462. internet fragment
  4463.           A portion of the data of an internet datagram with an internet
  4464.           header.
  4465.  
  4466. IRS
  4467.           The Initial Receive Sequence number.  The first sequence
  4468.           number used by the sender on a connection.
  4469.  
  4470. ISN
  4471.           The Initial Sequence Number.  The first sequence number used
  4472.           on a connection, (either ISS or IRS).  Selected on a clock
  4473.           based procedure.
  4474.  
  4475.  
  4476.  
  4477. [Page 72]                                                               
  4478.  
  4479.  
  4480. August 1979                                                             
  4481.                                            Transmission Control Protocol
  4482.                                                                 Glossary
  4483.  
  4484.  
  4485.  
  4486. ISS
  4487.           The Initial Send Sequence number.  The first sequence number
  4488.           used by the sender on a connection.
  4489.  
  4490. leader
  4491.           Control information at the beginning of a message or block of
  4492.           data.  In particular, in the ARPANET, the control information
  4493.           on an ARPANET message at the host-IMP interface.
  4494.  
  4495. left sequence
  4496.           This is the next sequence number to be acknowledged by the
  4497.           data receiving TCP (or the lowest currently unacknowledged
  4498.           sequence number) and is sometimes referred to as the left edge
  4499.           of the send window.
  4500.  
  4501. letter
  4502.           A logical unit of data, in particular the logical unit of data
  4503.           transmitted between processes via TCP.
  4504.  
  4505. local packet
  4506.           The unit of transmission within a local network.
  4507.  
  4508. module
  4509.           An implementation, usually in software, of a protocol or other
  4510.           procedure.
  4511.  
  4512. MSL
  4513.           Maximum Segment Lifetime, the time a TCP segment can exist in
  4514.           the internetwork system.
  4515.  
  4516. octet
  4517.           An eight bit byte.
  4518.  
  4519. Options
  4520.           An Option field may contain several options, and each option
  4521.           may be several octets in length.  The options are used
  4522.           primarily in testing situations; for example, to carry
  4523.           timestamps.  Both the Internet Protocol and TCP provide for
  4524.           options fields.
  4525.  
  4526. packet
  4527.           A package of data with a header which may or may not be
  4528.           logically complete.  More often a physical packaging than a
  4529.           logical packaging of data.
  4530.  
  4531.  
  4532.  
  4533.  
  4534.  
  4535.  
  4536.                                                                [Page 73]
  4537.  
  4538.  
  4539.                                                              August 1979
  4540. Transmission Control Protocol
  4541. Glossary
  4542.  
  4543.  
  4544.  
  4545. port
  4546.           The portion of a socket that specifies which logical input or
  4547.           output channel of a process is associated with the data.
  4548.  
  4549. process
  4550.           A program in execution.  A source or destination of data from
  4551.           the point of view of the TCP or other host-to-host protocol.
  4552.  
  4553. PSN
  4554.           A Packet Switched Network.  For example, the ARPANET.
  4555.  
  4556. RCV.BS
  4557.           receive buffer size, the remote buffer size
  4558.  
  4559. RCV.LBB
  4560.           receive last buffer beginning
  4561.  
  4562. RCV.NXT
  4563.           receive next sequence number
  4564.  
  4565. RCV.UP
  4566.           receive urgent pointer
  4567.  
  4568. RCV.WND
  4569.           receive window
  4570.  
  4571. receive last buffer beginning
  4572.           This is the sequence number of the first octet of the most
  4573.           recent buffer.  This value is use in calculating the next
  4574.           sequence number when a segment contains an end of letter
  4575.           indication.
  4576.  
  4577. receive next sequence number
  4578.           This is the next sequence number the local TCP is expecting to
  4579.           receive.
  4580.  
  4581. receive window
  4582.           This represents the sequence numbers the local (receiving) TCP
  4583.           is willing to receive.  Thus, the local TCP considers that
  4584.           segments overlapping the range RCV.NXT to
  4585.           RCV.NXT + RCV.WND - 1 carry acceptable data or control.
  4586.           Segments containing sequence numbers entirely outside of this
  4587.           range are considered duplicates and discarded.
  4588.  
  4589.  
  4590.  
  4591.  
  4592.  
  4593.  
  4594.  
  4595. [Page 74]                                                               
  4596.  
  4597.  
  4598. August 1979                                                             
  4599.                                            Transmission Control Protocol
  4600.                                                                 Glossary
  4601.  
  4602.  
  4603.  
  4604. RST
  4605.           A control bit (reset), occupying no sequence space, indicating
  4606.           that the receiver should delete the connection without further
  4607.           interaction.  The receiver can determine, based on the
  4608.           sequence number and acknowledgment fields of the incoming
  4609.           segment, whether it should honor the reset command or ignore
  4610.           it.  In no case does receipt of a segment containing RST give
  4611.           rise to a RST in response.
  4612.  
  4613. RTP
  4614.           Real Time Protocol:  A host-to-host protocol for communication
  4615.           of time critical information.
  4616.  
  4617. Rubber EOL
  4618.           An end of letter (EOL) requiring a sequence number adjustment
  4619.           to align the beginning of the next letter on a buffer
  4620.           boundary.
  4621.  
  4622. SEG.ACK
  4623.           segment acknowledgment
  4624.  
  4625. SEG.LEN
  4626.           segment length
  4627.  
  4628. SEG.SEQ
  4629.           segment sequence
  4630.  
  4631. SEG.UP
  4632.           segment urgent pointer field
  4633.  
  4634. SEG.WND
  4635.           segment window field
  4636.  
  4637. segment
  4638.           A logical unit of data, in particular a TCP segment is the
  4639.           unit of data transfered between a pair of TCP modules.
  4640.  
  4641. segment acknowledgment
  4642.           The sequence number in the acknowledgment field of the
  4643.           arriving segment.
  4644.  
  4645. segment length
  4646.           The amount of sequence number space occupied by a segment,
  4647.           including any controls which occupy sequence space.
  4648.  
  4649. segment sequence
  4650.           The number in the sequence field of the arriving segment.
  4651.  
  4652.  
  4653.  
  4654.                                                                [Page 75]
  4655.  
  4656.  
  4657.                                                              August 1979
  4658. Transmission Control Protocol
  4659. Glossary
  4660.  
  4661.  
  4662.  
  4663. send last buffer beginning
  4664.           This is the sequence number of the first octet of the most
  4665.           recent buffer.  This value is use in calculating the next
  4666.           sequence number when a segment contains an end of letter
  4667.           indication.
  4668.  
  4669. send sequence
  4670.           This is the next sequence number the local (sending) TCP will
  4671.           use on the connection.  It is initially selected from an
  4672.           initial sequence number curve (ISN) and is incremented for
  4673.           each octet of data or sequenced control transmitted.
  4674.  
  4675. send window
  4676.           This represents the sequence numbers which the remote
  4677.           (receiving) TCP is willing to receive.  It is the value of the
  4678.           window field specified in segments from the remote (data
  4679.           receiving) TCP.  The range of sequence numbers which may be
  4680.           emitted by a TCP lies between SND.NXT and
  4681.           SND.UNA + SND.WND - 1.
  4682.  
  4683. SND.BS
  4684.            send buffer size, the local buffer size
  4685.  
  4686. SND.LBB
  4687.           send last buffer beginning
  4688.  
  4689. SND.NXT
  4690.           send sequence
  4691.  
  4692. SND.UNA
  4693.           left sequence
  4694.  
  4695. SND.UP
  4696.           send urgent pointer
  4697.  
  4698. SND.WL
  4699.           send sequence number at last window update
  4700.  
  4701. SND.WND
  4702.           send window
  4703.  
  4704. socket
  4705.           An address which specifically includes a port identifier, that
  4706.           is, the concatenation of an Internet Address with a TCP port.
  4707.  
  4708.  
  4709.  
  4710.  
  4711.  
  4712.  
  4713. [Page 76]                                                               
  4714.  
  4715.  
  4716. August 1979                                                             
  4717.                                            Transmission Control Protocol
  4718.                                                                 Glossary
  4719.  
  4720.  
  4721.  
  4722. Source Address
  4723.           The source address, usually the network and host identifiers.
  4724.  
  4725. SYN
  4726.           A control bit in the incoming segment, occupying one sequence
  4727.           number, used at the initiation of a connection, to indicate
  4728.           where the sequence numbering will start.
  4729.  
  4730. TCP
  4731.           Transmission Control Protocol:  A host-to-host protocol for
  4732.           reliable communication in internetwork environments.
  4733.  
  4734. TOS
  4735.           Type of Service, an Internet Protocol field.
  4736.  
  4737. Type of Service
  4738.           An Internet Protocol field which indicates the type of service
  4739.           for this internet fragment.
  4740.  
  4741. URG
  4742.           A control bit (urgent), occupying no sequence space, used to
  4743.           indicate that the receiving user should be notified to do
  4744.           urgent processing as long as there is data to be consumed with
  4745.           sequence numbers less than the value indicated in the urgent
  4746.           pointer.
  4747.  
  4748. urgent pointer
  4749.           A control field meaningful only when the URG bit is on.  This
  4750.           field communicates the value of the urgent pointer which
  4751.           indicates the data octet associated with the sending user's
  4752.           urgent call.
  4753.  
  4754.           
  4755.  
  4756.  
  4757.  
  4758.  
  4759.  
  4760.  
  4761.  
  4762.  
  4763.  
  4764.  
  4765.  
  4766.  
  4767.  
  4768.  
  4769.  
  4770.  
  4771.  
  4772.                                                                [Page 77]
  4773.  
  4774.  
  4775.                                                              August 1979
  4776. Transmission Control Protocol
  4777.  
  4778.  
  4779.  
  4780.  
  4781.  
  4782.  
  4783.  
  4784.  
  4785.  
  4786.  
  4787.  
  4788.  
  4789.  
  4790.  
  4791.  
  4792.  
  4793.  
  4794.  
  4795.  
  4796.  
  4797.  
  4798.  
  4799.  
  4800.  
  4801.  
  4802.  
  4803.  
  4804.  
  4805.  
  4806.  
  4807.  
  4808.  
  4809.  
  4810.  
  4811.  
  4812.  
  4813.  
  4814.  
  4815.  
  4816.  
  4817.  
  4818.  
  4819.  
  4820.  
  4821.  
  4822.  
  4823.  
  4824.  
  4825.  
  4826.  
  4827.  
  4828.  
  4829.  
  4830.  
  4831. [Page 78]                                                               
  4832.  
  4833.  
  4834. August 1979                                                             
  4835.                                            Transmission Control Protocol
  4836.  
  4837.  
  4838.  
  4839.                                REFERENCES
  4840.  
  4841.  
  4842.  
  4843. [1]  Postel, J. (ed.), "Internet Protocol," Defense Advanced Research
  4844.      Projects Agency, Information Processing Techniques Office, IEN 111,
  4845.      August 1979.
  4846.  
  4847. [2]  Feinler, E. and J. Postel, ARPANET Protocol Handbook, Network
  4848.      Information Center, Stanford Research Institute, Menlo Park, CA,
  4849.      January 1978.
  4850.  
  4851. [3]  Dalal, Y. and C. Sunshine, "Connection Management in Transport
  4852.      Protocols," Computer Networks, Vol. 2, No. 6, pp. 454-473,
  4853.      December 1978.
  4854.  
  4855.  
  4856.  
  4857.  
  4858.  
  4859.  
  4860.  
  4861.  
  4862.  
  4863.  
  4864.  
  4865.  
  4866.  
  4867.  
  4868.  
  4869.  
  4870.  
  4871.  
  4872.  
  4873.  
  4874.  
  4875.  
  4876.  
  4877.  
  4878.  
  4879.  
  4880.  
  4881.  
  4882.  
  4883.  
  4884.  
  4885.  
  4886.  
  4887.  
  4888.  
  4889.  
  4890.                                                                [Page 79]
  4891.  
  4892.